Last updated 3 years ago
We can use head with the -c or --bytes flag to remove a number of bytes from the end.
head
-c
--bytes
So, if we want to remove a single newline from the input (or any character for that matter):
-c, --bytes=[-]NUM print the first NUM bytes of each file; with the leading '-', print all but the last NUM bytes of each file
$ echo "stuff" | head -c -1