Error: Tar command not found
11,308
You're saving something into PATH
which is what the shell will search to find the executables. So when you use that variable the shell can't find, say, tar
because it is no longer in your search path. Use a different variable name.
Related videos on Youtube
Author by
Patrick Kang
Updated on September 15, 2022Comments
-
Patrick Kang about 1 year
echo "Enter path of backup file e.g /tmp/backup/etc.tar.gz : " read PATH #input was /tmp/backup/etc.tar.gz echo "Enter directory: " read DIR #input was /root/testing sudo tar -zvxf "$PATH" -C "$DIR"
when I ran the script, it said that the command was not found. I tried using whatever kind of brackets for the variables but still not working. Any help?
However when I ran the command tar -zvxf /tmp/backup/etc.tar.gz -C /root/testing , it worked.
-
John Bollinger over 8 yearsThe
sudo
issue revolves aroundsudo
requiring the user to enter their password manually, when the script runs. As long as that's acceptable, there is no problem withsudo
in a script.
-