LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Cent OS Linux i have lots of .zip files. (http://www.linuxquestions.org/questions/linux-newbie-8/cent-os-linux-i-have-lots-of-zip-files-910628/)

dhirendrs 10-28-2011 07:22 AM

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 .

colucix 10-28-2011 05:17 PM

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/



All times are GMT -5. The time now is 04:46 AM.