0

This has been driving me mad for the past hour or so. I have four variables, $A, $B, $C, and $D. For simplicity's sake, let's assume that the values in each of those variables is their corresponding letter. I have tried to create a variable to hold a string I'd like to print, like so:

s="${A} failed. ${B} ${C} ${D}"
echo "$s"

I've written a test script exactly like so, and it works perfectly. However, in my actual script, the variables are different.

echo $table_name (prints correctly)
echo $source_count (prints correctly)
echo $disk_size (prints correctly)
echo $hive_count (prints correctly)
s="${table_name} failed. ${source_count} ${disk_size} ${hive_count}" (only prints $disk_size and $hive_count)
echo "$s"

Can anyone think of a reason that $s only seems to store the $disk_size and $hive_count? Is there any character limit to what can be stored in a variable?

1 Answer 1

3

$source_count has a CR at the end. Strip it before using the variable.

Sign up to request clarification or add additional context in comments.

1 Comment

How can I buy you a beer? Thank you for saving my sanity.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.