Littlee
Littlee

Reputation: 4327

Remove line break in string

I'm trying to create a zsh alias to copy the current pwd to clipboard

alias cpwd="pwd | pbcopy"

but the copied string always has a line break in the end of stirng, how do I remove it ?

Upvotes: 3

Views: 527

Answers (1)

Littlee
Littlee

Reputation: 4327

the solution provided by @Charles Duffy works!

printf '%s' "$(pwd)" | pbcopy

and I also have found another one, using tr

pwd | tr -d '\n\r' | pbcopy

Upvotes: 1

Related Questions