How can I use a single command to unzip every file in a directory, into a new unique directory with the same name as the file How can I use a single command to unzip every file in a directory, into a new unique directory with the same name as the file bash bash

How can I use a single command to unzip every file in a directory, into a new unique directory with the same name as the file


for f in *.zip; do  dir=${f%.zip}  unzip -d "./$dir" "./$f"done


Simple one liner

$ for file in `ls *.zip`; do unzip $file -d `echo $file | cut -d . -f 1`; done


you can use -d to unzip to a different directory.

for file in `echo *.zip`; do    [[ $file =~ ^(.*)\.zip$ ]]    unzip -d ${BASH_REMATCH[1]} $filedone