Need help with sed, the stream text editor

Under development: PCMCIA, wireless, etc.
Post Reply
Message
Author
User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

Need help with sed, the stream text editor

#1 Post by BarryK »

Guys, does anyone know how to do this:

Code: Select all

echo "textA      textB" | sed -e 's///g'
The above line is incomplete.
What I want to do is detect "textA", one or more spaces, then "textB", and replace it with something else.
The something else, doesn't matter.
The problem is, how do I detect an arbitrary number of spaces?

Code: Select all

echo "textA      textB" | sed -e 's/textASOMETHINGHERE textB/replacement/g'
It's a regular expression thing probably, which I am weak at.

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#2 Post by MU »

Code: Select all

echo "textA      textB" | sed -e 's/textA\W\+textB/REPLACEMENT/g'
\W =Whitespace (Spaces and Tabs)
\+ = one time or more



Mark

Guest

#3 Post by Guest »

mark, thanks!

Post Reply