I have a file that contains four columns and 5000 rows. I want to make 5000 new files from this file so that each file has one row from the original file. Also, I want to name the new files according to the values in the 4th column. Example: The following file (XXXX.txt) has four rows
File: XXXX.txt
1 315 4567 G1
1 212 345 G2
2 315 25674 G3
3 12 235673 G4
Expected New Files
File: G1
1 315 4567 G1
File: G2
1 212 345 G2
File: G3
2 315 25674 G3
File: G4
3 12 235673 G4
I have tried this command:
awk '{print > $0}' < XXXX.txt
This command makes new files as desired, but I am not able to name new files as per column4 of the original file.