find ./ -type f -name "*.tgz" -exec sh -c 'tar -xzf "$0" -C {}' \; tar (child): sh:…
- User
find ./ -type f -name "*.tgz" -exec sh -c 'tar -xzf "$0" -C {}' ; tar (child): sh: Cannot open: No such file or directory
- Assistant
The error message you are receiving indicates that the
shcommand is not found or there is no file namedshpresent in the current directory.To fix this issue, you can try the following solutions:
-
Make sure the
shcommand is available on your system by checking its location:codewhich shIf the command is not found, you may need to install it.
-
If the
shcommand is available, but not in the current directory, you can specify its absolute path in theexeccommand:codefind ./ -type f -name "*.tgz" -exec /bin/sh -c 'tar -xzf "$0" -C {}' {} \;Replace
/bin/shwith the actual path of theshcommand on your system. -
If you want to extract the
.tgzfiles in the current directory, you can use the.notation instead of{}:codefind ./ -type f -name "*.tgz" -exec tar -xzf {} -C . \;
-
- User
find ./ -type f -name ".tgz" -exec /bin/sh -c 'tar -xzf "$0" -C {}' {} ; find: missing argument to `-exec'
- Assistant
Apologies for the confusion. It looks like there is a small error in the provided command. The argument passed to
-Cin thetarcommand should be the destination directory, not{}.Please try the following modified command:
shellfind ./ -type f -name "*.tgz" -exec tar -xzf '{}' -C ./ \;This command will find all files with the
.tgzextension in the current directory and its subdirectories. Then it will extract the contents of each.tgzfile in the corresponding directory.Make sure to run this command in the desired directory where you want the files to be extracted.