Split Seven Rows In Per Column
There is only one column in the file,I want to split seven rows in per column
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
the result is
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
• 2,829 views
•
link
1 answer
Your question is not clear, because you said that you have a file that contains only one column, but then you show an example of a file that contains only one row.
case 1: split a file that contains one row and multiple columns
This are the contents of your file:
$: cat filenumbers
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
You want to split it into files containing 7 numbers each:
==> myresultaa.ok <==
1 2 3 4 5 6 7
==> myresultab.ok <==
8 9 10 11 12 13 14
==> myresultac.ok <==
15 16 17 18 19 20 21
==> myresultad.ok <==
22 23 24 25 26 27 28
Code:
sed 's/ /\n/g' filenumbers.txt | split -l 7 - temporary_results_
find . -maxdepth 1 -iname "myresult*" -print0 | xargs -0 -I filename sh -c 'paste filename -s -d" " > "filename.ok"; rm filename' -- {}
• 12 views
•
link
Log in to answer this question.
tip: try to use awk, using a loop
for(i=1;i<= NF;i++) if(i%7....You already asked a few questions on this site
and received some valuable responses: but did not validate any answer. Please, do.
If I can I would ,I am learning perl.Thank you your tip,I will try it
http://partmaps.org/era/unix/award.html#cat
There is no connection to bioinformatics and therefore the question must be closed.