Search code examples
linuxcentosclipboardxclip

How to make xclip strip newline from the output piped to it?


this is the command responsible for adding a new line to the string

echo "string" | xclip -selection clipboard

Solution

  • echo -n "string" | xclip -selection clipboard
    

    I should probably have elaborated a bit. The default for echo is to output the string AND a newline. -n suppreses the latter.