Some Useful Linux Command Lines for Manipulating CSV Files

Shen Lu
Posted on Aug 31, 2023
views
1 min read (109 words)
Recently I am working on a site. The most tedious work is generating and collecting data. Today I list some frequently used Linux commands for manipulating CSV files.
Delete the Nth Column
Here is the example that If you want to delete the 12th column in CSV file
cut -d, -f12 --complement older.csv > newer.csv
Add Line Number As First Column
awk '{printf "%s,%s\n", NR,$0}' older.csv > newer.csv
Delete First Column
sed -r 's/^[^,]+,//' older.csv > newer.csv
Copy images from one folder to another
find /one/folder -iname \*.jpg -print0 | xargs -I{} -0 cp -v {} /another/folder