The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
find command with exec doesnt work funtochat2002 Shell Programming and Scripting 6 07-26-2006 02:29 PM
Find command with prune and exec options Sebarry UNIX for Dummies Questions & Answers 2 06-19-2006 04:07 AM
Find command with prune and exec Sebarry UNIX for Advanced & Expert Users 1 06-18-2006 01:43 PM
find command exec error pavan_test UNIX for Dummies Questions & Answers 2 06-13-2006 03:58 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-23-2009
max29583 max29583 is offline
Registered User
  
 

Join Date: Dec 2006
Location: UK
Posts: 33
find command with -exec

Hi People,

I have a directory full of compressed files (.Z extention)
In many of these files there is a string pattern (3800078163033)

I want to find all file names which contain this string in their text.

Regards,
Abhishek
  #2 (permalink)  
Old 04-23-2009
lavascript lavascript is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 47
Do you mean in the filename itself or within the actual compress file?

If you mean just the filename then :-

Code:
find *3800078163033*.Z
should work.

If you mean within the file then i'm not sure if there's an equivalent as below for files compressed with compress but if they were gzipped or bzipped there is bzcat and gzcat so you could do :-

Code:

string="3800078163033"

for file *.Z
do
   if [[ -n "$(gzcat $file | grep $string)" ]];then
       echo "File [$file] contains string [$string]"
   fi
done
  #3 (permalink)  
Old 04-23-2009
max29583 max29583 is offline
Registered User
  
 

Join Date: Dec 2006
Location: UK
Posts: 33
Thanks Lavascript...I wnated the 2nd solution and it Worked!!!
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 05:07 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0