Re: OT: Which tool, and how, to get partial string from file?
From: Miquel van Smoorenburg (miquels_at_cistron.nl)
Date: 08/20/04
- Previous message: Alec Berryman: "Re: Different default browser"
- In reply to: Kent West: "OT: Which tool, and how, to get partial string from file?"
- Next in thread: Kent West: "Re: OT: Which tool, and how, to get partial string from file?"
- Reply: Kent West: "Re: OT: Which tool, and how, to get partial string from file?"
- Reply: John Summerfield: "Re: OT: Which tool, and how, to get partial string from file?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 20 Aug 2004 21:24:19 +0000 (UTC) To: debian-user@lists.debian.org
In article <41265EB6.2050202@acu.edu>,
Kent West <westk@acu.edu> 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
then
# word was present in file
bla
bla
fi
Or "if ! grep -q word file" if you want to do something if word
wasn't present in file.
Mike.
-- 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 listmaster@lists.debian.org
- Previous message: Alec Berryman: "Re: Different default browser"
- In reply to: Kent West: "OT: Which tool, and how, to get partial string from file?"
- Next in thread: Kent West: "Re: OT: Which tool, and how, to get partial string from file?"
- Reply: Kent West: "Re: OT: Which tool, and how, to get partial string from file?"
- Reply: John Summerfield: "Re: OT: Which tool, and how, to get partial string from file?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|