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

Re: OT: sed -n vs. sed



On Sat, May 15, 2004 at 07:15:17PM -0600, Bob Proulx wrote:
>   sed -n '/PATH/p' /etc/profile

That produces the exact same output as "grep PATH /etc/profile".
Why not just use grep?

>   sed -n '/^+/q;p' /etc/passwd

None of the lines in my /etc/passwd start with +, but in in a file thus 
so I get identical output with "sed '/^+/Q'".

>   sed -n '/^+/,$p' /etc/passwd

That one seems useful, because "sed '0,/^+/d'" does not include the line 
starting with +, and I can see no way to express the address 
start,up-to-but-not-including-regex.

I think I can see how -n would be useful once you start using hold 
space, but at that point I usually just move to perl.



Reply to: