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.

Share:
11,308

Related videos on Youtube

Patrick Kang
Author by

Patrick Kang

Updated on September 15, 2022

Comments

  • Patrick Kang
    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
      John Bollinger over 8 years
      The sudo issue revolves around sudo requiring the user to enter their password manually, when the script runs. As long as that's acceptable, there is no problem with sudo in a script.