Search code examples
linuxshelltcsh

How to split a text file into a fixed width file in tcsh?


I need to read a text file and make it fit X amount of columns.

For example, if my text.txt contains:

ABCDEFGHIJK

the resulting file for a width of 4 should be:

ABCD
EFGH
IJK

Solution

  • Like this?

    $ echo ABCDEFGHIJK | sed -r 's/(....)/\1\n/g'
    ABCD
    EFGH
    IJK