AWK/Perl for extracting data from txt file to numerous other files
I'm new to both Perl and AWK. I have a text file with tens of thousands of lines arranged by year 1953-2005.
The first line, first field is 'CAN14A2005010101'.
If I use:
awk '/CAN14A2005/' ottawa.txt > ottawa2005.txt
in my cygwin bash window,it performs the operation that I want by copying all the data entries for 2005 and writing them to a new file named appropriately.
I want to avoid having to type that for each year, whats the best way to write a script that will use the awk command and do it for each year? Should I write it in a perl script and use awk commands within that?
If I need to clarify anything, please let me know. Any help would be greatly appreciated!