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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

for-loop

Status
Not open for further replies.

Simmy

Technical User
Sep 7, 2002
27
GB
Can you help?
I have a file in this format: aa bbb cc d ee but I want it in this format: aa/bbb/cc/d/ee.
I want to do this with AWK and I've been told that I should use a for-loop but I can't figure out how to do it.
Maybe you can?
Thanks a lot.
 
Here's my suggestion.
Code:
{
  printf $1
  for (i=2;i<=NF;i++) printf &quot;/&quot; $i
  print &quot;&quot;
}
Hope this helps. CaKiwi
 
It works,
thanks.
I think I will be using this forum a lot!
 
BEGIN {
OFS=&quot;/&quot;
}

{ gsub(FS, OFS); print $0 }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top