I'm trying to split my second column in the file below after every 4 characters.
file.txt
>1A THISISATEST
>1B THATISATEST
desired output:
>1A THIS ISATEST
>1B THAT ISATEST
After searching and attempting to modify, I tried to use this sed command: sed 's/(.{4})(.{7}).*/\2 \3/' file.txt
. However, I can't seem to get it to work. Am I missing something? However, if you have an awk
suggestion, that would also be helpful. Also, please explain your suggestions. I'm in the learning process of awk
and sed
.
\
in front of each{
and}
. However, you should anchor the expression with^
per jimmij's post. Otherwise, sed will match a random set of 4 and then 7 characters.awk
solution I gave works for you ?