hi Gurus,
I need separate a file which is one huge line to multiple lines based on certain number of charactors. for example:
abcdefghi high abaddffdd
I want to separate the line to multiple lines for every 4 charactors.
the result should be
abcd
efgh
i hi
gh a
badd
ffdd
Thanks in advance.
Yoda
2
You can use fold
command:
fold -w4 file
1 Like
Thank you very much!
you are great!!!
Jotne
4
With awk
awk '{for (i=1;i<=length($0);i+=4) print substr($0,i,4)}' file
1 Like
Thanks, the code works perfect. Great man !!!
For completeness:
sed 's/.\{4\}/&\
/g' file
Yes, sed needs two lines. GNU sed also takes one line with \n
.