Easiest way to strip newline character from input string in pasteboard
I wrote a utility called noeol
to solve this problem. It pipes stdin to stdout, but leaves out the trailing newline if there is one. E.g.
pwd | noeol | pbcopy
…I aliased copy
to noeol | pbcopy
.
Check it out here: https://github.com/Sidnicious/noeol
pwd | tr -d '\n' | pbcopy
printf $(pwd) | pbcopy
or
echo -n $(pwd) | pbcopy
Note that these should really be quoted in case there are whitespace characters in the directory name. For example:
echo -n "$(pwd)" | pbcopy