Neha Singh
Neha Singh

Reputation: 73

Split files on the basis of length

I have a file,the total length of the file should be 454 for one row. Any character after 454 should move in the next row .

After col5 the length is 454, i need that from col1 it should move to the next line

Input file:

col1col2col3col4col5col1col2col3col4col5col1col2col3

Expected Output file:

col1col2col3col4col5
col1col2col3col4col5
col1col2col3

Upvotes: 0

Views: 104

Answers (2)

Neha Singh
Neha Singh

Reputation: 73

Its not splitting the whole length into 454 characters each.

0064208520010012009070199991231459 GRACE AVE PANAMA CITY FL324012756 BAY 8502156007 [email protected] NYpanama c001 I0 0 1 17530101 *U*00656812600200120090701999912312215 BURDETT AVE TROY NY121802466 RENSSELAER 5182713300 5182713681 [email protected] YYtroy 001 I0 0 1 17530101 U

Here you can see U is the end of the first row and then the new row starts . So i Want that 0065 line should come in the next line.

Fold and fmt command are not working correctly

Upvotes: 0

oliv
oliv

Reputation: 13259

If you want a 'hard' break at 454 character, use fold command:

fold -w 454 file

If your input file contains text, and you don't want to break words, use fmt command:

fmt -w 454 file

Upvotes: 1

Related Questions