Bash Fold Long Text File Wrap Help

Chris Barry

Registered
I have a note file for a client that varies in length from 100-1000 characters in length. My issue is for them to be able to import it into their system it has to be in a certain format that contains the first 50 characters as format then the next 150 for the actual note. I need to be able to fold wrap or what ever the whole note but keep the first 50 characters as it contains account number and some formatting for their system. I'm new to writing scripts as well and came across something that I feel can help make this work but not sure how to write it out. What I found was a bash scrip that is just "fold -150" this wraps each line of the note at 150 characters. Is there a way to say copy first 50 while folding the next 150? Then exporting this whole thing to a new file? If this doesn't make sense please let me know and I can try and explain it more.


Sent from pay phone in the airport.
 
Suppose your note file is named note.txt. The following command writes the first 50 bytes to standard output.
head -c 50 note.txt
The next one passes the rest of the file to your fold command.
tail -c +51 note.txt | fold -150
You can combine these as follows.
( head -c 50 note.txt; tail -c +51 note.txt | fold -150 ) > newnote.txt

Sorry to be a wee bit late.
 
Suppose your note file is named note.txt. The following command writes the first 50 bytes to standard output.
head -c 50 note.txt
The next one passes the rest of the file to your fold command.
tail -c +51 note.txt | fold -150
You can combine these as follows.
( head -c 50 note.txt; tail -c +51 note.txt | fold -150 ) > newnote.txt

Sorry to be a wee bit late.

Thanks this worked great
 
Back
Top