Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parse and merge text files with specific content 1

Status
Not open for further replies.

czarj

Technical User
Apr 22, 2004
130
US
Hey everyone.

I'm trying to write a script that will parse through a huge directory of small text files and merge all files with a common line of text. For example, I want to merge all files that share the line "Kay-BUL" or perhaps all the files that have "PI:ST" (and only those files).

Any help would be greatly appreciated.

CzarJ
 
man find
man xargs
man grep (the -l option)
man cat

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
i agree PHV
egrep is also usefull
g.e.: egrep -li... "kay-bul|pi:st" *
check the syntax, see man pages, as PHV suggested

:) guggach
 
Got it... thanks

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
for i in `find . -name '*' -print | xargs grep -l Kay-BUL`
do
cat $i >> sumfile
done
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top