Perl Pie (aka perl -p -i -e)

Few days ago a co-worker came to me for an advice and he said the following “I have a huge file that has 2 million records and I would like to change a date in it from 04/29/2012 to 04/15/2012.” He emphasized that there was only one column that has that date.

In order to solve the problem I went ahead and executed this statement on unix command line:

$ perl -p -i -e 's|04/29/2012|04/15/2012|g' file

The run time was few seconds and all records got updated properly.

Leave a Reply

Your email address will not be published. Required fields are marked *