Computing.Net > Forums > Unix > Insert line breaks in ASCII file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Insert line breaks in ASCII file

Reply to Message Icon

Name: Sonthalia
Date: July 15, 2003 at 17:19:51 Pacific
OS: UNIX
CPU/Ram: SunFire
Comment:

Hi,

I've a UNIX ASCII file with one long string line. I need to break this long line into multiple lines so that each line has 94 characters.

Thanks for your help in advance.
Alok



Sponsored Link
Ads by Google

Response Number 1
Name: Jimbo
Date: July 16, 2003 at 00:09:12 Pacific
Reply:

if the 'fold' command is on your system, try:

fold -w 94 your_file


-jim


0

Response Number 2
Name: David Perry
Date: July 16, 2003 at 06:51:08 Pacific
Reply:

I did the following when I needed to wrap something to 70 characters / line.

awk '{ll=int(length($0)/70) ; i=1 ; \
if (length($0)>72) { \
{ print substr($0,0,70) } \
while (i<=ll) { { print " " substr($0,i*70+1,70) } i=i+1} \
} else { \
{ print ($0) } } }'


0

Response Number 3
Name: Sonthalia
Date: July 16, 2003 at 14:10:33 Pacific
Reply:

fold command worked great.

fold -w 94 myfile > newfile

Thanks Jim and all who responded.

Regards,
Alok


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


FTP files in an interval Delete last character in ...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Insert line breaks in ASCII file

Script to insert lines in a file www.computing.net/answers/unix/script-to-insert-lines-in-a-file/4992.html

copy and past in a file www.computing.net/answers/unix/copy-and-past-in-a-file/8112.html

scan ascii file and do calculation www.computing.net/answers/unix/scan-ascii-file-and-do-calculation/4328.html