Hi All,
I have a big file which looks like this:
0 4.5 6.7
0 3.4 6
1 5 6
1 6 4
2 9 4.44
Above is just a miniature version of the file. In fact, considering the first column of the file that is 0 0 1 1 2, the numbers in actual go until 10442.
This means my actual file looks like this:
0 4.5 6.7
0 3.4 6
1 5 6
1 6 4
2 9 4.44
..
..
10442 5 4.333
What I want to do is to look in the first column, extract all the lines which have 0 in the beginning and store in the file 1.num
Referring to the above example, this is what I mean:
0 4.5 6.7
0 3.4 6
The above numbers go in file, 1.num
1 5 6
1 6 4
Lines which begin with 1, go in file named 2.num
Subsequently,
10442 5 4.333
goes in file 10443.num
The number of lines containing 0's or 1's or 10442's is not fixed. This means I have to look at the first number from each line and keep storing the lines with the same number in the same file.
I am not able to figure it out as to how to tackle this but I show as to what I have done:
awk '{print $1} {c++}{print > c."num"}' scores.sce
The above code has following problems:
- I am not able to put in the searching part that is the part which searches for 0 or 1 or 2 etc in the beginning of every line.
- It gives syntax error message.
I am using Linux with BASH.