I had to modify a file for loading into an Oracle database with SQL*Loader. The file was using as field delimiter the | pipe character and each line was ending in a |. So ideally, I would like to remove the pipe chracter that ends each of the 384 016 850 lines of my text file.
One option is to use vim macros but I chose to use sed. The Linux command that would work is:
sed -i 's/.$//' filename
but I noticed with surprise that this command would not work in mac OS!
After a bit of investigation, I found out that the sed implementation on macOS is a bit different so the command on macOS is:
sed -i '' 's/.$//' filename
note the extra characters that make the difference!