I have a large data file and want to split it into smaller files based on values in column 1. For example column 1 has numbers from 1 to 10 ten times to make 100 rows and I want all lines with numbers '1' or '2' or '3' etc in their own file (preferably without sorting). Also I dont want to run the command 10 times so would like for it to be in a loop.
My files look like this:
The command I tried:
cat ID.txt | while read line; do awk '$1 == ${line}' test.txt >$line.txt;done
So to summarize I want it to read the value from the ID.txt file e.g '1' and then extract all rows with '1' in the first line and put it in a file called 1.txt, then it iterates to 2 then 3 then 4 etc.
But somehow the '$1 == ${line}' part I think is not working