Skip to content
Advertisement

echo does not print a variable in bash

I’m facing a very strange issue. I have 2 files ber_log_before.txt and ber_log_after.txt. Their contents are

ber_log_before.txt

JavaScript

ber_log_after.txt

JavaScript

There are $ it’s normal.

Then I wrote a basic bash command to parse them

JavaScript

Why 1st val 14 2em val 24 is not echoed???

If I replace

JavaScript

by

JavaScript

Then at least I have 2em val echoed.

I guess that awk can do the job, but that’s not the question.

Advertisement

Answer

This is not a problem actually, or it was me the problem. both files I mentioned are created from a telnet session (with expect command to be more specific). So all lines are ending with r and of course echo 1st val 14r 2em val 24r will ‘overwrite’ the first part of the echo. So I replace the r by n and then it’s ok.

To understand the problem, I copied my command into a script and use set -x. It was easy to find the r.

Sorry for that stupid question.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement