[Pdx-pm] command line options

Randal L. Schwartz merlyn at stonehenge.com
Wed May 19 16:27:31 CDT 2004


>>>>> "Thomas" == Thomas J Keller <kellert at ohsu.edu> writes:

Thomas> Simple question, but I can't find the answer.
Thomas> I want to do the simplest thing: read a tab delimited file with Mac
Thomas> ('\cM' carriage return) endings, and remove extra whitespace.

Thomas> I wrote this on the command line:
Thomas> perl -i.bak -pe 'local $/ = "\cM';  s/[\s\t]+/\t/g;' input.txt

Thomas> It removes the extra whitespace, but doesn't keep the line endings,
Thomas> i.e. output is a single line.

Thomas> I also tried the -0 option with "\cM", but that gave an error.

Untested:

        perl -015 -i.bak -pe 's/\s+/\t/g' input.txt

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



More information about the Pdx-pm-list mailing list