Reputation: 1
I need to concatenate a string into a file through a command that is a single valued argument to a script:
defining sample text:
TEXT="sample text"
defining characteristic script : transfer.sh
$1
desired usage (to be corrected):
./transfer.sh "echo $TEXT >> test.log"
desired output in test.log
... (previous contents)
sample text
Upvotes: 0
Views: 72
Reputation: 3563
You can use eval
command in your transfer.sh
file:
eval $1
It will generate test.log
with "sample text" in the last line. Be aware that anything you pass to transfer.sh
script will be executed. So, if your user passes "rm -r /home/alan/papers"
, everything in your papers
folder will be deleted.
Upvotes: 1