You are not logged in.
Pages: 1
This is run in two different machines. In machine 1 cat cannot read variables but does in machine 2.
[root@localhost ~]$ echo "This is a test" >test.tmp
[root@localhost ~]$ TEST=$(cat test.tmp)
[root@localhost ~]$ cat $TEST
cat: This: No such file or directory
cat: is: No such file or directory
cat: a: No such file or directory
cat: test: No such file or directory
[root@localhost ~]$
[root@zeus /tmp] $ echo "This is a test" >test.tmp
[root@zeus /tmp] $ TEST=$(cat test.tmp)
[root@zeus /tmp] $ echo $TEST
This is a test
[root@zeus /tmp] $
Markku
Offline
I don't understand why this is strange. Here is what I get:
# echo "This is a test" >test.tmp
# TEST=$(cat test.tmp)
# cat $TEST
cat: This: No such file or directory
cat: is: No such file or directory
cat: a: No such file or directory
cat: test: No such file or directory
# echo $TEST
This is a test
# set
...
TEST='This is a test'
...
From what I know $() takes precedence over =
Drew
Knowledge Brings Fear
Sweet, now I can play with myself.
Offline
exactly.
in one you are trying to cat the filename held in the TEST variable.
Since TEST="This is a test", you are trying to cat "this is a test"...
so cat tries to find each of the files
on the second one, you are just echoing the contents of the TEST variable.
seems fine to me.
"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍
Offline
on the second one, you are just echoing the contents of the TEST variable.
seems fine to me.
When I received the machine 2's reply, after corresponing about cat, I took for granted machine 2 used cat $TEST not echo $TEST.
Thanks, problem solved.
Markku
Offline
Pages: 1