zip) in one directory, you can use the script provided in this post to inflate them into the directories with the same name as the original archive, that is:
file1.zipwill get inflated to
file2.tarwill get inflated to
file3.tar.gzwill get inflated to
So here is the script:
#!/bin/bashcd $1for i in $(ls)dodir_name=$(echo $i | sed "s/\([^.]*\)[.].*/\1/")if [[ "$i" =~ "zip" ]]; thenmkdir -p $dir_namecd $dir_name;unzip $icd ../elif [[ "$i" =~ "tar.gz" ]]; thenmkdir -p $dir_namecd $dir_nametar -xzvf ../$icd ../elif [[ "$i" =~ "tar" ]]; thenmkdir -p $dir_namecd $dir_nametar -xvf ../$icd ../fidone
The argument to this code is the full path of the directory that contains the archived files. Notice that the script searches for the strings, "tar", "zip" and "tar.gz" in the filenames. If you have other files in the directory which contain these strings in their names, they can get overwritten!
You can save the script using a name of your choice (I have named it
open.sh, as indicated in the terminal output shown below)
terminal$ ls directory_path/file1.tar file2.zip file3.tar.gzterminal$ ./open.sh directory_path/terminal$ ls directory_path/file1 file1.tar file2 file2.zip file3 file3.tar.gz
I would like to thank Girish Venkatasubramanian for advice on this script.