Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add a single char without over duplicating a string 1

Status
Not open for further replies.

grazinggoat

Programmer
Joined
Mar 12, 2008
Messages
41
Location
US
Hello,

I've tried this with (off topic sed) but could not get it to work.
Is the a method in awk so that i can take a line like this:

a ba baa aab ab aaa aa a bab aba

to get this:

aa baa baa aab aab aaa aa aa baab aabaa

basically when ever there is a double aa ignore it
but add a a where it see's a "a"

Any thoughts please?

 
A starting point:
Code:
awk '{for(i=1;i<=NF;++i)if($i!~/aa/)gsub(/a/,"aa",$i);print}' /path/to/input >output

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top