I’m new with bash script and now trying to make a back-up file using it. What I’m facing is below script (line 47 in my bash file),
$(tar -czvPf ${folder_backup}/rajal/backup.tgz -C /var/www/tmk/app .)
always gimme error on the shell ./test: line 47: ./: Is a directory, while it works on Terminal, nicely.
FYI, folder app is folder with files and subfolders.
Could someone help me out? Thank you for any help.
means: execute
commandand return its output. To illustrate, it is very often used like this:After this is evaluated,
resultwill hold whatever the commandfoo 4 123output.If you use that construct directly – not as an argument to another command, or in a variable assignment, the shell will try to execute the output of the command. While this is sometimes wanted, it often is not, and that’s what you’re seeing.
So just remove the
$( )from your command and runtardirectly. If you want to capture the output oftar, either redirect it to a file or use the construct above.Do note that
$(command)and${env_var_name}are completely different. Syntax matters.