Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Shell error: Value too great for base (error token is "168a")

I get this error message for my shell script below:

./my_script.sh line 17: f1bfab2e-168a: value too great for base (error token is "168a")
data=($( jq -r '.data' data.json  | tr -d '[]," ' ))

for i in "${data[@]}"; do
  echo "${data[i]}"
done

(data is made up of array elements that are a series of letters and numbers such as f1bfab2e-168a-4da7-9677-5018e5f97g0f )

I’ve referenced other Stack Overflow posts that provide solutions such as variable indirection or characters getting interpreted as octal numbers but I have been unable to resolve this error.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

When using variable indirection such as

data=($( jq -r '.data' data.json  | tr -d '[]," ' ))

for i in "${data[@]}"; do
  echo "${data[${!i}]}"
done

"${data[${!i}]}" ends up only referencing the first array element for some reason. So if my array has two elements abc123 and bcd234, then what gets printed is just
abc123 abc123
instead of
abc123 bcd234.
I don’t exactly understand why and what’s going on there.

Additionally, I don’t think that bash is interpreting any of my characters as octal numbers here so a solution for that situation does not apply to my case.

What significance does 168a have to bash?

>Solution :

The i is already the item of the array, not the index, as you seem to believe. This should work:

for i in "${data[@]}"; do
  echo "$i"
done
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading