![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to search for text within compressed file | HLee1981 | UNIX for Advanced & Expert Users | 8 | 09-06-2007 03:50 AM |
| Line count for compressed files | swamy455 | Shell Programming and Scripting | 1 | 08-02-2007 07:40 PM |
| Search in a file and get the next line as well | turi | UNIX for Dummies Questions & Answers | 2 | 07-02-2007 02:20 PM |
| search and retrieve previous line in file | paulsew | Shell Programming and Scripting | 2 | 02-23-2007 04:04 AM |
| In Line File Modifications: Search and Replace | Shakey21 | Shell Programming and Scripting | 2 | 11-20-2001 12:21 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Search first line of compressed file
I want to read a directory full of compressed files and move the file to another directory if it meets certain criteria. I only want to look at the first line of the compressed file and if I find the string, do the move. I am currently using the following:
zgrep -R -L IH120070731/psoft/bnydata/etl/BNY_CRDW_UAT/source_archive/08012007 | xargs -i {} mv {} ../20070731/{} This does fine and doesn't run too bad if most of the files will be moved. It takes forever for the zgrep to go through every line of every file when I really only want to check the first line. Any ideas on how to limit the search to the first line only? Thanks in advance. |
| Forum Sponsor | ||
|
|
|
|||
|
instead of using a zgrep ...try using a zcat as below
DIRECTORY=<Location where the files are located> NEWDIR=<Desination folder> for file in `ls -1 $DIRECTORY/*.Z` do LC=`zcat $file |head -1|grep "${STRING}"|wc -l` if test $LC -eq 1 then mv $file $NEWDIR/. fi done |
|||
| Google The UNIX and Linux Forums |