Thursday, July 22, 2010

Quick Image resize

for a in $(find . -iname \*.jpg); do convert $a -resize 640x480 small/$a; done

Wednesday, July 7, 2010

data integrity check from CSV

To test the data integrity in your CSV file and locate any lines that contain the delimiter in the data field so that it can be removed manually.

Regular Expression:

Will select lines that contain 4 or more pipes per line.
(?: ) is a non-capturing group. Similar to ( ), except that it doesn't store the result for later reference.

A more greedy approach is to write something like this:

This will match lines that contain only four pipes

Test it:

Or using ruby one-liners:

#print only lines that match a regular expression (emulates 'grep')
$ ruby -pe 'next unless $_ =~ /regexp/' < file.txt

#print only lines that DO NOT match a regular expression (emulates 'grep')
$ ruby -pe 'next if $_ =~ /regexp/' < file.txt