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!

Script to break file into 80 char recs 1

Status
Not open for further replies.

ls62

Programmer
Oct 15, 2001
177
US
Hi,

I have a text file that has no newlines in it and I want to break it into 80 character records with newlines after every 80 chars. I know there's a command to easily do this, but can't remember. I thought it was 'dd' but can't seem to figure syntax out.

Can anyone help?

Thanks.

LEE
 
Thank you, thats the command I needed! I knew someone would know right away.

Again. Thanks [2thumbsup]
 
Ok... I should have asked this before. I receive a file in 80 char blocks with some character as the record separator. Is there a command to remove the 81st character. I know I could use 'tr' to delete that character if I new what it was, but what if it was variable... what command could I use?

Thanks

LEE
 
pls provide a sample input AND a sample output. It'll make it easier to understand the objective.

vlad
 
In this particular case I have records with 80 characters and then a n/l. I want to strip out the n/l. Generally speaking that n/l character could be any (ie bell, ack, ~) character.
 
Sorry, the cut command doesn't work because it outputs a n/l after each 'cut' line is outputted.

If I cut -c1-40 ,for example, I get 40chars then n/l.

Thanks.
 
ls62:

The problem is not with the cut command; it's probably with whatever your output command is. If you're using Korn Shell, use the printf command:

printf("%s", "123")

prints string "123" with no new-line.

If you don't have ksh, use awk:

echo "123"|awk ' { printf("%s", $0) } '

Regards,

Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top