LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 10-28-2011, 07:22 AM   #1
dhirendrs
Member
 
Registered: Nov 2009
Posts: 32

Rep: Reputation: 15
Cent OS Linux i have lots of .zip files.


Cent OS Linux i have lots of .zip files. need to move some specifics files.

I have big no of .zip file in one directory .

when i am executing ls -ltr *.zip argument to long message.

I need to identified zip files in all as below logic.

I have below type of zip files containt.

1)791.20081028113936.zip

Extract containt :

791.20081028113936.sku.iu
791.20081028113936.plu.iu
791.20081028113936.pluext.iu

If .zip extract and if it has plu.iu inside i have to move those .zip files to other directory in loop for all present file from source directory.


if it not containt plu.iu extract part of zip it will keep it there in that location.

More important i dont want to do any extract of .zip files it should be work with out extract it containt should be read as it is .zip file and move to other location . also need to view or ls befor move .
 
Old 10-28-2011, 05:17 PM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,458

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
I'm not sure the following will gives the same "argument list too long" error, anyway you might give it a try:
Code:
for file in *.zip
do
  if unzip -l $file | grep -q plu.iu$
  then
    mv $file /path/to/destination/dir
  fi
done
If you get the error above, we need to change the logic to avoid the usage of the huge list in a single statement/command.

To list the files, you can go up by one level and list the content of the directory, e.g
Code:
$ cd ..
$ ls directory_containing_zip_files/

Last edited by colucix; 10-28-2011 at 05:19 PM.
 
  


Reply

Tags
script, scripts, shell script, unix


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux zip program's -d -tt option deletes all files from zip archive Arun Gupta Linux - Software 4 04-27-2011 07:06 PM
How to zip several files to several zip with one command? thomas2004ch Linux - Newbie 4 02-08-2010 08:13 AM
How do I extract password pretected .zip files in linux i_s Linux - General 2 03-25-2005 04:47 AM
Unzipping .zip files in linux dr_zayus69 Linux - Software 5 09-27-2004 06:47 PM


All times are GMT -5. The time now is 02:16 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration