07 Mar

Changing separator with Perl

This will join all lines of a file together. Sometimes I have a list of something in a file, one line per item and want to convert it to a comma(colon,tab)-separated line (with no trailing separator of course) that can be used as a command-line parameter to some other tool.

perl -e '@_=; chomp(@_); print join(";",@_);' < data_file