- Unix provides a command to directly split a line using length of new lines. There is a command 'fold' to do this:
fold -
e.g. fold -2000 file > outputFile.
It will break all the lines in file "file" into lines of maximum length 2000 characters.
- Another way to do this is using sed or perl command. Using this command line can be broke around a character and also minimum number of character can be defined in each new line
perl -pe 's/(.{1,199}[ ,])/\1\n/g'
In this command,
.{1,199} - it will search the split character after 200 character only.
[ ,] - split character is either space pr comma.
\1\n - once split character is found, it will replace the line with first part of line (upto 200 character and then adds newline character.
No comments:
Post a Comment