![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| sed to find a pattern | shyjuezy | UNIX for Dummies Questions & Answers | 2 | 05-22-2008 10:03 AM |
| Count of matched pattern occurance | palash2k | UNIX for Dummies Questions & Answers | 3 | 04-24-2008 04:33 PM |
| String search - Command to find second occurance | saurabhsinha23 | UNIX for Dummies Questions & Answers | 5 | 12-06-2007 08:03 PM |
| Pattern searching pattern in c files | murthybptl | Shell Programming and Scripting | 6 | 11-17-2007 09:15 AM |
| find pattern in FILES and replace it ?? | tamer | UNIX for Dummies Questions & Answers | 4 | 03-03-2001 10:30 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How to find files which has more than one occurance of pattern
Hello Everyone,
Please help me in finding out the solution. The problem is .. lets say i have 600 files in a directory. All 600 files are shell script files. Now i need to find out the files which contains a pattern "SHELL" more than once. No matter how the pattern occurs , it can be in same line or in different lines also. I hope there must be some fair way to do this. Please help me. ![]() Thanks, |
|
||||
|
Quote:
Code:
find /directoryname -name "*.sh" -o -name "any other pattern" | xargs grep -i "SHELL" or just be in that directory and grep for the pattern grep "pattern" * |
|
||||
|
The first one just greps, the second will list files which don't have any matches at all. But try this: Code:
grep -cr SHELL directory | grep -v ':[01]$' ... provided your grep can do -r (recurse a directory). |
![]() |
| Bookmarks |
| Tags |
| grep or |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|