티스토리 뷰

공부

[sh] cmd -> echo & eval

승가비 2022. 12. 15. 19:20
728x90
cmd="rm .gitignore"
echo "$cmd"
eval "$cmd"

https://unix.stackexchange.com/questions/356534/how-to-run-string-with-values-as-a-command-in-bash

 

How to run string with values as a command in bash?

Here is my small bash script snippet. i=5 command='echo $i' $command I want this script to print 5 i.e., I want it to run echo and print 5. But it instead keeps printing $i. So how do I go about

unix.stackexchange.com

 

728x90
댓글