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

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -