I have this file containing 8 veritcal lines and I need to cut the first two lines into a new file and then cut the next two lines into a new file and so on... any help would be much appreciated. I tried the cut -c but that doesnt work and I am not sure what else to try.
Thanks.
If by vertical row, you mean something like this:
one two three four five six seven eight
one two three four five six seven eight
one two three four five six seven eight
And you want all ones and twos in file1, all threes and fours in file2 etc. then this might work for you:
#!/usr/bin/env ksh
awk '
{
for( i = 1; i < NF; i += 2 )
{
of = sprintf( "file%s", int((i/2)+1) );
printf( "%s %s\n", $(i), $(i+1) ) >of;
}
}
'
exit
It creates one file for every two columns in each input line.