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

a stupid performance Q 4

Status
Not open for further replies.

iribach

Technical User
Oct 12, 2002
211
CH

input is
abcde123456

output is
abc
de1
234
56

insert a \n after every 3.char (if present)

the inputfile is large, very very large
sed does not understand \n,
maybe i don't understand sed
vi can do it
:%s/.../&^M/g
but, needs days to do the job
it's a performance Q.
any idea? thanks iribach
 
Try...
[tt] fold -3 infile > outfile[/tt]
Or...
[tt] dd conv=unblock cbs=3 if=infile of=outfile[/tt]
 
Something like this ?
sed 's!...!&^M!g' /path/to/input | tr '\015' '\012' >output

in ksh, to have ^M type Ctrl+V Ctrl+M (in vi editing mode)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
thank you both
fold is new to me
dd is really performant
sed also, maybe i mistyped the ^M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top