简体   繁体   中英

How to remove newline character when copying to clipboard

I'm using alot readlink command, and what I'm trying to do is to create a short cut for this. I've added this to ~/.bashrc

rl() { readlink -f "$1" | xclip -i -selection clipboard; }

But when I want to paste it by pressing ctrl+v , terminal is trying to execute a command. Which is not what I want, I suspect it because there is a newline character at the end.

So the question is how to make this command copy to the clipboard and make the cursor stay at the the same line when pasting it?

Just found an answer:

  -n, --no-newline do not output the trailing newline 
rl() { readlink -fn "$1" | xclip -i -selection clipboard; }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM