To remove all newlines you could, say:
tr -d '\n' < days.txt
cat days.txt | tr -d '\n'
but how would you use tr
to remove just the newline at the end/bottom of a text file?
I'm not sure to specify just the last one.
A simpler solution than the accepted one:
truncate -s -1 <<file>>
From the truncate
man page (man truncate
):
-s, --size=SIZE
set or adjust the file size by SIZE
SIZE may also be prefixed by one of the following modifying characters:
'+' extend by, '-' reduce by, '<' at most, '>' at least, '/' round down
to multiple of, '%' round up to multiple of.