perl -pe 'chomp if eof' filename >filename2
or, to edit the file in place:
perl -pi -e 'chomp if eof' filename
[Editor's note: -pi -e
was originally -pie
, but, as noted by several commenters and explained by @hvd, the latter doesn't work.]
This was described as a 'perl blasphemy' on the awk website I saw.
But, in a test, it worked.
How to create an array from a CSV file using PHP
How to pass an array within a query string?
Insert new item in array on any position in PHP
How to check whether an array is empty using PHP?
Converting an integer to a string in PHP
How can I add elements to an empty array in PHP?
How to find the foreach index?
How can I capture the result of var_dump to a string?