I wish to unzip ZIP files from a text list, each one into its own folder and output the errors into a log file.
The list looks like this:
0001.zip
0002.zip
I know i can use the following command but I just don't know how
to accomplish the above.
find -name '*.zip' -exec sh -c 'unzip -d "${1%.*}" "$1"' _ {} \;
Thank you.
Best Answer
Since you already have the extraction command
sh -c 'unzip -d "${1%.*}" "$1"'
, you can usexargs
to convert input files to arguments:The
{}
is not needed sincexargs
by default appends the input to argument list. The-L1
makes it use one line of input as an argument.Then just redirect the output to a file:
Or just the errors: