Hi All,
I've got a directory full of csv files: 1.csv, 2.csv, 3.csv and so on. What I'm trying to do is read each csv file and rename that file based on the output of line 2 in that file. For instance: cat 1.csv | awk 'NR==2' would return blue, I want to rename 1.csv to blue.csv. I've tried a few different things including:
ls *.csv > list
for i in `cat list`;do cat $i |awk 'NR==2 {print "mv "$i" "$1".csv"};done > executeme
The file executeme would then be ran and change the name of each of the files. However, the execute file doesn't have what exactly what I want (mv blue blue.csv). And, I believe a better / faster way of going about this is out there. Or, I just need to make some adjustments. Anyhow, any help or suggestions would be greatly appreciated.
TIA!!