[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: Which tool, and how, to get partial string from file?



Thomas Adam wrote:

On Fri, Aug 20, 2004 at 03:27:34PM -0500, Kent West wrote:
solution. I'm hoping one of you whiz-guys can provide me an answer in about ten seconds.

Is this want you want (as an example):

[n6tadam@station ~]$ echo this is a word in a line | grep -o word word

So for your script:

grep -o "word" ./file

If I understand you correctly.

Maybe, maybe not:
summer@Dolphin:~$ echo this is a word in a line | grep -o wor
wor
summer@Dolphin:~$

This:

summer@Dolphin:~$ echo this is a word in a line | grep  wor     | tr ' ' '\n'  |grep  wor
word
summer@Dolphin:~$

I use two greps because sometimes the input file is fairly large. You can also sort (or sort -u), and it's good to prequalify the data then too.



-
Cheers
John

-- spambait
1aaaaaaa@computerdatasafe.com.au  Z1aaaaaaa@computerdatasafe.com.au
Tourist pics http://portgeographe.environmentaldisasters.cds.merseine.nu/



Reply to: