Dear All, I would be happy if anyone can suggest me command (Sed or AWK one line command) to divide each line of file in equal number of part. For example divide each line in 4 part.
Input:
ATGCATHLMNPHLNTPLML
Output:
ATGCA THLMN PHLNT PLML
Dear All, I would be happy if anyone can suggest me command (Sed or AWK one line command) to divide each line of file in equal number of part. For example divide each line in 4 part.
Input:
ATGCATHLMNPHLNTPLML
Output:
ATGCA THLMN PHLNT PLML
echo ATGCATHLMNPHLNTPLML | perl -plane '$s = int((length $_) / 4) + 1; s/(.{$s})/$1 /g;'
ATGCA THLMN PHLNT PLML
More than one way to skin a cat in perl :-)
echo ATGCATHLMNPHLNTPLML | perl -lane '$lag = "a4" x((length $_)/4); @seqs = unpack $lag, $_; print join " ", @seqs'
Your second example works fine with my code.
input TGCATHLMNPHLNTPLMLATGCATHLMNPHLNTPLML
output TGCA THLM NPHL NTPL MLAT GCAT HLMN PHLN TPLM
When I am giving 38 character as input it gives 4 part; 3 part with 10 charter and last with 8. While I am expecting 2 part with 10 characters and last 2 with 9 character
Input: TGCATHLMNPHLNTPLMLATGCATHLMNPHLNTPLML
Output: ATGCATHLMN PHLNTPLMLA TGCATHLMNP HLNTPLML 10 Char 10 char 10 char 8 char
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
When I am giving 38 character as input it gives 4 part; 3 part with 10 charter and last with 8. While I am expecting 2 part with 10 characters and last 2 with 9 character
Input: TGCATHLMNPHLNTPLMLATGCATHLMNPHLNTPLML
Output: ATGCATHLMN PHLNTPLMLA TGCATHLMNP HLNTPLML 10 Char 10 char 10 char 8 char
try my unpack below...