I love one-liners1 to make my life easier. Today I decided to clean up a directory full of CSV files, and compress them down. After all, a 2MB CSV file can be reduced quite substantially, and I had 300 of them.
Here it is, quite simply loops through the directory of CSVs, and zips the file up, keeping the name the same.
for i in `ls -1 *.csv`; do zip -m ${i%csv}zip ${i}; done
This all goes on a single line, but can easily be written out over multiple lines, like this:
for i in `ls -1 *.csv`;
do
zip -m ${i%csv}zip ${i}
done
Doing this reduced the folder size down from 600MB, to about 70MB, about an eighth the size.
-
a script that can be written onto a single line, and executed ↩