Serach a pattern


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Serach a pattern
# 1  
Old 05-10-2010
Serach a pattern

Hi,

I am trying to find a particular patter in multiple UNIX files (also contain system files,hidden files and normal files)

i am now using
CMD: egrep -ali 'pattern' *

i am not getting the required result, i just need files path and finename

Naveen
# 2  
Old 05-10-2010
Code:
egrep -li 'pattern' $( ls -a /tmp/tmp1/*)

Replace /tmp/tmp1 by path to files
# 3  
Old 05-10-2010
This cmd is not looking into .ini,.cshrc ....ectc files.and even not looking into sub directories.

egrep -li 'pattern' $`( ls -a /tmp/tmp1/*)` >> files2.txt

Naveen
# 4  
Old 05-10-2010
Try
Code:
find . | xargs grep -li 'pattern' 2>/dev/null

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to get a value from a file and serach that value filename in a dir?

buddies, my requirement would be as follows, I have a file called test.txt and content of it would be yahoo gmail hotmail and i want to search a file name called "yahoo.html" (first line of test.txt) and then "gmail.html" and then "hotmail.html" in a /home/test dir. Any idea... (8 Replies)
Discussion started by: natraj005
8 Replies

2. Shell Programming and Scripting

Script to Serach pattern and give number of occurrences

Hi, I want a script which search for a pattern "good" in a huge file and provide me number of occurences of such pattern in a file. lets say i have a file test.txt contents as below good is good but good is sometime bad and sometime good you are very good and good is always good ... (7 Replies)
Discussion started by: sv0081493
7 Replies

3. UNIX for Dummies Questions & Answers

Serach pattern in one field and replace in another

Hi all, I have a TAB separated file like this: sample.rpt: 54 67 common/bin/my/home {{bla bla bla}} {bla bla} Replace Me 89 75 bad/rainy/day/out {{ some bla} } {some bla} Dontreplace Me ...... ...... I wish to do a regexp match on the 3rd... (2 Replies)
Discussion started by: newboy
2 Replies

4. Shell Programming and Scripting

WildCard serach for files in a directory

Hi i have a requirement to search for all files in a directory. the files will start as file1_*,file2_*,file3_* where the wild card character is a timestamp. so on a particular day i may get files like file1_1103120042 file1_1102010345 file2_1101093423 file3_1103120042... (3 Replies)
Discussion started by: Sgiri1
3 Replies

5. Shell Programming and Scripting

pattern serach using grep

Frds I have to search for a string which is starting with brighton which will be first in the line of a text file test1.txt. The contents of test1.txt are file names like ----- brighton brighton_gt hst_brighton gst_brighton -------so many files------ --------- i have retrieve only... (3 Replies)
Discussion started by: KiranKumarKarre
3 Replies

6. UNIX for Dummies Questions & Answers

Pattern Matching - serach and replace script

My requirement is to replace a a particular pattren in a script from A to B. I am not sure if this can be done through sed command or through awk . The file sv.inc is window DialogBox AddConnection tag "~ActiveApp/Add Connection - Provider Type?URL" I would wnat the file to be... (10 Replies)
Discussion started by: bsandeep_80
10 Replies

7. Shell Programming and Scripting

serach and replace a specific pattern or value in a xml file

can some one help me with a perl command i have to search and replace a version from a xml-file so i use in a ksh script a command like this ssh $GLB_ACC@$GLB_HOST "/usr/contrib/bin/perl -pi -e "s/$curVersion/$new_Version/g" $Dest_dir/epi.xml" this command worked so far, but the problem... (1 Reply)
Discussion started by: kiranreddy1215
1 Replies

8. Shell Programming and Scripting

serach file using awk

Hi, I was able to print lines when search for specific string using awk but i want to print when search for two different strings using awk instead of doing two times (Print lines only contain "Insert Records and Insert into" not between lines) Ex: awk '/Insert Records./' a4.log It... (3 Replies)
Discussion started by: mohan705
3 Replies

9. UNIX for Advanced & Expert Users

Serach and delete

Hi, This is the format of the file that i have CompanyNumber Run Date: 8/3/2006 6:22:15PM Address: Person: A03120 SP SNNu 100 1 200 2 CompanyNumber ... (3 Replies)
Discussion started by: kkm_job
3 Replies

10. Shell Programming and Scripting

Case-insensitive serach with awk

Is there any way to do case insensitive search with awk for the below statement: month1=`awk '/month/' ${trgfile} | cut -d"=" -f2` the "month" could come as Month, mOnth,MONTH etc. in a file. Now I am looking for "month".... Thanks, AC (4 Replies)
Discussion started by: acheepi
4 Replies
Login or Register to Ask a Question