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
.
Best Answer
Here is a solution with
awk
. It separates first four characters and rest of the 2nd column into two variables and print them.