command in variable
I am making a pipeline of several commands.
This is a part of my shell script. ----------------------------------- array=( "mkdir src" "ls -l | grep tk_ > src/list" ) len=${#array[*]} i=0; while [ $i -lt $len ]; do echo ${array[$i]} if !(${array[$i]}); then exit 1; fi; let i++ done --------------------------------------- "mkdir src" is working well but "ls -l | grep tk_ > src/list" does not work. These are error messages. ----------------------------------------- ls: cannot access |: No such file or directory ls: cannot access grep: No such file or directory ls: cannot access tk_: No such file or directory ls: cannot access >: No such file or directory ls: cannot access src/list: No such file or directory ----------------------------------------- How can I solve this problem? Thanks. |
If you want the commands to work properly, then enclose them like this :
Code:
array=( |
Thanks but,
I think the commands in your code run at the moment when 'array' is created, not in the while loop.
Anyway thanks. |
All times are GMT -5. The time now is 11:36 PM. |