![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
help on awk
In a file directory, how can I only get the file-name which contains a pattern inside the file using awk?
for example, there are 3 text files in a directory, file_1, file_2, file_3 I'd like to find the file (I need file name only, not the line contains the pattern) which the file body contains a word "testing". How can I do it using awk? Thanks Last edited by ting123; 04-07-2006 at 02:54 PM. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Try this
ls -1 | awk '/testing{1,}/'
|
|
#3
|
|||
|
|||
|
why awk?
Code:
ls *testing* |
|
#4
|
|||
|
|||
|
the purppose I want is find the file which contains a pattern in the file, not in the file name
|
|
#5
|
||||
|
||||
|
Quote:
|
|
#6
|
|||
|
|||
|
In this particular case, the line in the file is too long to over the "grep" command's limitation, so neither "grep" or "egrep" or "fgrep" won't work. That's why I need find out how to do it either "awk" or "sed"
Best |
|||
| Google The UNIX and Linux Forums |