I have a bunch of CSV files in a directory like:
modfinalak_1.csv modfinalal_1.csv modfinalal_2.csv modfinalal_3.csv modfinalar_1.csv modfinalar_2.csv
so it's one or multiple files per each US state (AK, AL, AR, etc.). How can I use cat to combine all the files for each state and then rename the file to the state name?
In the above example, I want modfinal_1.csv,modfinalal_2.csv,and modfinalal_3.csv to be combined and renamed to al.csv. How do you get cat to do this based on the text before the '_' character?