Extract .tar File to Current Directory Automatically with Shell Script Extract .tar File to Current Directory Automatically with Shell Script shell shell

Extract .tar File to Current Directory Automatically with Shell Script


You can try:

-C, --directory DIR              change to directory DIR

and $(dirname "$x") for file directory

for x in in /home/davidwright/attachments/*/*.tardo  echo "extracting $x"  tar -xvf "$x" -C "$(dirname "$x")"done