linux - echo command behaviour issue in bash -
command="echo 'hello world' > file.txt"; $command;
and i'm expecting write "hello world" text file.txt, prints whole string as,
'hello world' > file.txt
what wrongs code?
after variable replaced, result scanned word splitting , wildcard expansion. other special shell characters, such quotes , redirection, not processed. need use eval
reprocess completely:
eval "$command"
Comments
Post a Comment