variable question
in the following there is a 0 outputted from 'z=ls | wc -w' and i first thought that z would equal 'ls | wc-w' but was confused about the 0, then i thought that the first command z=ls was being piped to wc -w, but then when echoing z i get nothing. my question is what is happening when 'z=ls | wc -w' is run, and why is there a 0 outputted?
atlantis@linux:~> echo $z atlantis@linux:~> z=ls | wc -w 0 atlantis@linux:~> echo $z atlantis@linux:~> |
Try using back quotes:
Code:
z=`ls | wc -w` |
yeah, i understand what was wrong. but im just trying to figure out whats going on to output the 0
|
the command "z=ls" assigns "ls" to "z" but doesn't output anything, so when you count the words, it's 0
|
if it assigns ls to z then why when echoing $z does it not output ls?
|
because this does not assign ls to z:
Code:
z=ls | wc -w Code:
z=word word Code:
z=ls |
All times are GMT -5. The time now is 02:55 PM. |