0

I am facing a weird situation in UNIX.

I have 2 variables - var1 and var2

When I try to print the values: echo $var1$var2

It only print $var2 value. Similarly, if I do this with 3 variables, only the last variable's value gets printed...

Please help as to what the issue is and how it can resolved.

EDIT1: identified the issue - it was due to end-of-line characters

The following answer gave me the answer: https://stackoverflow.com/a/45772568/8336579

Mohak
  • 1
  • 1
  • Did you leave a space between the two vars? – Barry Carter Jul 07 '22 at 12:57
  • Yes Space, no space - same result – Mohak Jul 07 '22 at 14:02
  • But I found the issue - it was actually what value was there inside these 2 variables - the variable were reading value from a file - and that file had windows end-of-line characters (\r\n) - and then that value was passed to awk command - which was just interpreting the \n, thus leaving \r in the end - which was causing the cursor to return to the starting of line. The following answer proved super helpful: https://stackoverflow.com/a/45772568/8336579 – Mohak Jul 07 '22 at 14:05
  • Ah, yes, the dreaded linefeed character – Barry Carter Jul 07 '22 at 15:41

0 Answers0