200 awk.
echo "hello 1 2 3 4" | awk '{print ">"$1; for(i=2; i<=NF; i++) {printf("%d ",$i); if((i+1)%2 == 0) printf("\n");}}
>hello
1 2
3 4
, , hello,
echo "hello 1 2 3 4" | awk '/^hello / {print ">"$1; for(i=2; =NF; i++) {printf("%d ",$i); if((i+1)%2 == 0) printf("\n");}}
( / / : " , ".
if( (i + 1) % 2 == 0) if( (i + 1) % 100 == 0 ), 100 ... 2, .
, , .
: ( /^hello /, , "", {} , ).
/^hello/ { print ">"$1;
for(i=2; i<=NF; i++)
{
printf("%d ",$i);
if((i+1)%100 == 0) printf("\n");
}
print "";
}
awk -f breakIt inputFile > outputFile
: " breakIt inputFile outputFile".
.
, sed, ( ). sedSplit
s/^([A-Za-z]+ )/>\1\
/g
s/([0-9 ]{10})/\1\
/g
s/$/\
/g
sed; , , .
s/^ - substitute, starting from the beginning of the line
([A-Za-z]+ )/ - substitute the first word (letters only) plus space, replacing with
>\1\
/g - the literal '>', then the first match, then a newline, as often as needed (g)
s/([0-9] ]{10})/ - substitute 10 repetitions of [digit followed by space]
\1\
/g - replace with itself, followed by newline, as often as needed
s/$/\
/g - replace the 'end of line' with a carriage return
sed script :
sed -E -f sedSplit < inputFile > outputFile
-E ( - ..)
-f flag (' ')
- , Mac ( , , ).