I have a text file called file.txt like below,
01_ABC_0000 AA
02_CDE_0000 BB
03_EFG_0000 CC
04_ABC_0001 DD
05_CDE_0001 EE
06_EFG_0001 FF
where it should separated into two different files, like file0.txt
01_ABC_0000 AA
02_CDE_0000 BB
03_EFG_0000 CC
and file1.txt
04_ABC_0001 DD
05_CDE_0001 EE
06_EFG_0001 FF
what i have been trying,
cat file00.txt | awk '{print $1}' | sed 's/.*\(....\)/\1/') to get the only numbers from first word but I am not able use this to go forward separating it into the two files.
Any help is much appreciated.
EDIT: Sorry, I have edited the question where the first field is 01_ABC_0000 something like this, If I use field separator as underscore it doesn't work as expected.