ubanerjea
ubanerjea

Reputation: 474

Behavior of ECHO Command and Variable Usage in Unix

Can't post the image directly yet, so here's a link to it: https://i.sstatic.net/MOfIv.png

I'm trying to learn some basic unix file scripting for an Informatica project I'm working on. I've used a few scripts in the past and have only a very rudimentary idea of what to do so I'm just playing around with the various parts of an existing script.

I can't make heads or tails of some of the behavior of the commands. Here is an example using ECHO. The thing appears to just randomly return one of: the variable I defined, the variable name, or an error.

e.g. why does:
$ _Src="/home/axxxxxx"
$ echo "${_Src}"

return
/home/axxxxxx

but
$ INFA_HOME="/home"
$ echo "${INFA_HOME}"

returns
ksh: "${INFA_HOME_^H}": bad substitution

other inscrutable behavior:
$ echo "${INFA_HOME} now"
>
$ echo "${INFA_HOME} now"
/home now
$ echo "${INFA_HOME} "
{INFA_HOME}
$ echo "${INFA_HOME} now"
/home now

Upvotes: 0

Views: 454

Answers (2)

UserOp
UserOp

Reputation: 174

I think you should check your putty or terminal settings. You may see in the image below the string works as expected.

https://i.sstatic.net/5CQ1j.png

the screenshot that you shared shows "^H" which is equivalent to backspace, so the chances you might have used that. The next time you use the variable it prints the output as expected. Even with the first variable all goes fine.

Upvotes: 0

tripleee
tripleee

Reputation: 189397

Looks like your terminal has some issues. Make sure echo $TERM agrees with the emulation mode of the terminal, and that locales etc. are correctly set up.

Upvotes: 1

Related Questions