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

sql server - MSSQL Text and Varchar(MAX) fields shown (MEMO) in DBGrid -

php - Changing the visibility scope of parent methods in child classes -

qml - Is it possible to implement SystemTrayIcon functionality in Qt Quick application -