2

I am trying to get a list of folders in my directory 'KEAX', and then dive into each one of them.

After entering each folder, I want to run the command:

foreach f(*.tar)
tar -xvf$f
end

After running this command, I want to back out, and then go into the next folder that is in 'KEAX' and run the same command as above. However, I am getting an error running the above command

Byte Commander
  • 110,243
WX_M
  • 121

1 Answers1

1

This command should work. It searches for all *.tar files in the current directory recursively and cds into its location in a Bash subshell and unpacks it there for each result:

find . -iname '*.tar' -exec bash -c 'cd "$(dirname "{}")" ; tar -xvf "$(basename "{}")"' \;
Byte Commander
  • 110,243