You are not logged in.

#1 24 Jun 2012 12:38

shlinuxbash
Member
Registered: 24 Jun 2012
Posts: 2

Using multiple commands: sed

Hello, SS64 !

I've got a question. If I wanted to operate on the word one for instance I would do a:

echo one two | sed s/one/1/
Output: 1

The same with two:

echo one two | sed s/two/2/
Output: 2

But when I try to replace both, I get this:

echo one two | sed s/one/1/ s/two/2/
Output: couldn't read file s/two/2/

So, what am I doing wrong?

Thanks in advance, shlinuxbash

Offline

#2 24 Jun 2012 13:30

shlinuxbash
Member
Registered: 24 Jun 2012
Posts: 2

Re: Using multiple commands: sed

The desired output is:

1 2

Offline

#3 25 May 2013 10:43

Alfaq
Member
Registered: 25 May 2013
Posts: 1

Re: Using multiple commands: sed

echo one two | sed s/two/2/ | sed s/one/1/

Offline

#4 25 May 2013 12:48

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: Using multiple commands: sed

GNUsed can do this

echo one two | sed -e s/one/1/ -e s/two/2/

Offline

Board footer

Powered by