using awk to unzip files in directory

Khalid Abo El MaGd

I have some zip files in directory when I need to unzip each in specific dir I used

ls | awk '{ print "unzip " $1 " -d " $1} '
unzip p21286665_121020_Linux-x86-64.zip -d p21286665_121020_Linux-x86-64.zip
unzip p21841318_121020_Linux-x86-64.zip -d p21841318_121020_Linux-x86-64.zip
unzip p22098146_121020_Linux-x86-64.zip -d p22098146_121020_Linux-x86-64.zip

But I need something like this.

unzip p21286665_121020_Linux-x86-64.zip -d p21286665
unzip p21841318_121020_Linux-x86-64.zip -d p21841318
unzip p22098146_121020_Linux-x86-64.zip -d p22098146
Ralph Rönnquist

You could also use the -F argument to split the line on underscore and thus end up with something like this:

ls | awk -F_ '{print "unzip " $0 " -d " $1; }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Unzip files into a new directory

From Dev

How to unzip all the password protected zip files in a directory using Java

From Dev

How to unzip files into the current directory?

From Dev

How to unzip files into the current directory?

From Dev

Unzip many files to a given directory

From Dev

How to unzip .gz files in a new directory in hadoop?

From Dev

Python: Unzip selected files in directory tree

From Dev

awk directory of files

From Dev

Split files using awk and generate the results in another directory

From Dev

How to do filtering of multiple files in a directory using awk?

From Dev

How to copy all files in directory recursively and unzip compressed files on fly

From Dev

Unzip files using zip.js in phonegap

From Dev

unzip/untar files using Curl in ftp server

From Dev

Unzip ZIP files in separate folders using Powershell

From Dev

Shell script to unzip files using file watcher

From Dev

java - How to unzip all the files in a specific directory of a zip file?

From Dev

Using AWK to combine files

From Dev

How to search for docx file and unzip it in the given directory using java?

From Dev

Unzip a file into a target directory?

From Dev

Junk a part of the directory with unzip?

From Dev

unable to unzip to opt directory

From Dev

How to unzip into a given directory

From Dev

How to unzip into a given directory

From Dev

Unzip all files in a folder using 7zip in CMD line

From Dev

Unzip all zipped files in a folder to that same folder using Python 2.7.5

From Dev

Handling 3 Files using awk

From Dev

Compare two files with using awk

From Dev

Ant: unzip multiple files

From Dev

Unzip Files in iOS

Related Related

HotTag

Archive