Remove Whitespace using Perl

If you need to remove white space from say a CSV file that has been spooled by SQLPLUS, then try this:

 perl -pi.bak -e "s/^ *//g;s/ *,/,/g;s/, */,/g" C:\working\Batch\spooled_output.csv

This will remove leading spaces and any spaces in between comma separated values.

It will also create a *.bak file of your original.

 

Leave a Reply