I am trying to format data in a file that needs to be imported to a system. This system does not take more than 65 characters of text in a single line. So, I am trying to format the text in Description column to split as multiple lines as shown in sample below. It would be really helpful for the user if it is a single line Linux command, can you please check if it is possible?
Sample input in file -
Depth Description (ft) - 12370.0 LS: Mdst, blsh gry, sft, occ mod firm, crpxln, prly, arg, SLTST: blk, firm-mod hd, amor, gt, mod calc, CLST: lt gry-m gry, sft, amor, wxy 12400.0 LS: Mdst, blsh gry, mod firm, crpxln, chky, arg, SLTST: blk-dk gry, firm-mod hd, amor, gt, mod calc, CLST: lt gry-m gry, occ rdsh gry, mod firm, amor, wxy, tr CHK 12430.0 LS: Mdst, blsh gry, mod firm, crpxln, chky, arg, SLTST: blk-dk gry, firm-mod hd, amor, gt, mod calc, SH: blk-dk gry, mod firm, blky-plty, occ brit, wxy 12460.0 SH: blk-dk gry, mod firm, blky-plty, occ brit, ea, SLTST: blk-dk gry, firm-mod hd, amor, gt, mod calc, SST: gry-dk gry, wl consol, v f, ang, p srt, cotd, slily calc cmt, no fluor
Depth and Description and the line below it are considered headers. Depth column contains all numbers, Description column contains text that should be formatted as multiple lines for the system to accept the data.
Desired output with Linux command -
Depth Description (ft) - 12370.0 LS: Mdst, blsh gry, sft, occ mod firm, crpxln, prly, arg, SLTST: blk, firm-mod hd, amor, gt, mod calc, CLST: lt gry-m gry, sft, amor, wxy 12400.0 LS: Mdst, blsh gry, mod firm, crpxln, chky, arg, SLTST: blk-dk gry, firm-mod hd, amor, gt, mod calc, CLST: lt gry-m gry, occ rdsh gry, mod firm, amor, wxy, tr CHK 12430.0 LS: Mdst, blsh gry, mod firm, crpxln, chky, arg, SLTST: blk-dk gry, firm-mod hd, amor, gt, mod calc, SH: blk-dk gry, mod firm, blky-plty, occ brit, wxy 12460.0 SH: blk-dk gry, mod firm, blky-plty, occ brit, ea, SLTST: blk-dk gry, firm-mod hd, amor, gt, mod calc, SST: gry-dk gry, wl consol, v f, ang, p srt, cotd, slily calc cmt, no fluor
Note - User will not be able to install any Linux package on their machine. (example - par)
12460.0 SH: blk-dk gry, mod firm, blky-plty, occ brit,
contains 55 chars – RomanPerekhrest Sep 5 '17 at 16:34fmt
command (fromcoreutils
) e.g.fmt -tw65 file
– steeldriver Sep 5 '17 at 17:41