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

Re: regexp: anything but |



lee wrote:

On Wed, Dec 09, 2009 at 07:07:52PM +0000, Chris Jackson wrote:

Note that from the shell this is in single quote marks to stop shell
expansions. Doing it without those would be masochism ;)

It already is:


lee@yun:~/tmp/chan$ cat channels.dvb | sed '/^[^|]*|[^|]*-[0-9]|/' | wc -l
sed: -e Ausdruck #1, Zeichen 21: Fehlender Befehl
0
lee@yun:~/tmp/chan$

(which means: "expression #1, character 21: missing command" --- and
it matches every line)

But the idea behind your version is interesting :)


Well, you need to give it a command, I just gave you the regex. And the default in sed is to print every line. Try:


sed -n '/^[^|]*|[^|]*-[0-9]|/ p'

Where -n means don't print every line (technically it prints the "pattern space" at the end of processing each line), and p is the command meaning print - i. e. print those that match.

--
Chris Jackson


Reply to: