Re: OT: Which tool, and how, to get partial string from file?
From: Miquel van Smoorenburg (miquels_at_cistron.nl)
Date: Fri, 20 Aug 2004 21:24:19 +0000 (UTC) To: email@example.com
In article <41265EB6.firstname.lastname@example.org>,
Kent West <email@example.com> wrote:
>A programmer would know this . . , but not me ;-)
>I'm using a script to build a file by concatenating portions of two
>other files. Then end result needs to be checked to make sure a certain
>word shows up in a line.
>I know that "grep programm <this email message>" would return the line:
> A programmer would know this . . , but not me ;-)
>but what I want returned is just the word "programmer".
sed -ne 's/^.*\(word_here\).*$/\1/p' < file
BTW, why not simply
if grep -q word file
# word was present in file
Or "if ! grep -q word file" if you want to do something if word
wasn't present in file.
-- The question is, what is a "manamanap". The question is, who cares ? -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact firstname.lastname@example.org