[Top][All Lists]

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

Re: sed help

From: Joel J. Adamson
Subject: Re: sed help
Date: Mon, 28 Jan 2008 13:35:44 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

"Aaron Gray" <address@hidden> writes:

> "Dan C" <address@hidden> wrote in message 
> news:address@hidden
>> On Mon, 28 Jan 2008 14:48:19 +0000, Aaron Gray wrote:
>>> I need to print out all instances of the string expression
>>> 'this\-\>[a-zA-Z_]+' from a C++ file on separate lines.
>> OK, go ahead.
> ??? :)
> AFAICT sed will not do this. Tried awk but could not fathom it.

* grep prints lines that match a pattern
* tr transposes characters
* sed edits line by line and uses regular expressions to match text
* awk performs a huge variety of actions based on line-by-line addressing,
which may include pattern-matching

To do this in awk:
# awk '/<pattern/ {print}'
where '#' is your shell prompt.  However, this is much easier to do in
grep, since that's what grep is for.  You would only use awk if you
wanted to do something with it (something too complex or ungainly for sed).


Joel J. Adamson
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA  02114
(617) 643-1432
(303) 880-3109

reply via email to

[Prev in Thread] Current Thread [Next in Thread]