echo "string" | xclip -selection clipboard , copies the 'string' but also adds a new line to it. how to fix this?

user2453554 picture user2453554 · Jun 4, 2013 · Viewed 10.5k times · Source

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

echo "string" | xclip -selection clipboard

Answer

tink picture tink · Jun 4, 2013
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.