Data processing
Frequently Asked Questions
How to remove trailing whitespace from a file?
Run the sed command to trim any trailing whitespace.
sed -i 's/[[:space:]]*$//' FILE
How to insert a line at the beginning of a file?
Use the sed command and let it perform an inline replacement.
sed -i '1i # New first line' FILE