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

Manipulating Text Files

Status
Not open for further replies.

djrgk

Programmer
Jul 10, 2001
1
GB
I have a large text file and need to merge every 2 lines and then insert / after a set number of characters on the new lines.

The file is something like this:

B
afzWULod050a123456

I want it to look like this:

B/a/f/zWUL/od050a/123456

Anyone any ideas?
 

djrgk,

here is an idea:


NR % 2 != 0 { first = $0 }

NR % 2 == 0 {

print first "/" substr($0,1,1) "/" substr($0,2,1) "/" substr($0,3,4) "/" substr($0,7,6) "/" substr($0,13)

}

print line must be in one line (if wrapped).

Bye!

KP.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top