hi2_t
1
hi,
I am new script learner,
so my basic doubt is ,
how to store value of any command in a variable example
$ ls | wc -l
i want to stote the output of this in a variable c.
so that i can use c in if else loop.
and when do we use " ` " symbol in script..
can anyone also tell for learner whick ebook i should use..
to put command in variable....
var=$(ls | wc -l);echo $var
hi2_t
4
HI,
Thanks for reply,
can you please help me , i am trying to write just small script, for testing, i am getting error as follows..
count(){
var=$(ls | wc -l)
}
count
echo $var
loop_test(){
if [$var -eq 3]
then
echo "its true"
else
echo "its false"
fi
}
loop_test
ERROR:
$ ./script
3
./script: line 8: [3: command not found
hi2_t
6
Thanks protocomm, Franklin52, panyam
I am able to learn script with u all guys,
now my test script is running.
Thanks alot.