Direct/efficient way to chop off trailing \n
Paul.Domaskis
Paul.Domaskis@gmail.com
Wed Oct 1 23:11:00 GMT 2014
On 2014-10-01, Paul.Domaskis wrote:
> cygpath -aw foo | tr -d '\n' > /dev/clipboard
Gary Johnson wrote:
> Define a function in your ~/.bashrc.
>
> winclip()
> {
> cygpath -aw "$ <at> " | tr -d '\n' > /dev/clipboard
> }
>
> Then just execute
>
> winclip TheFile
Jim Garrison wrote:
> Sounds like cygpath needs a "-n" option which eliminates the
> trailing newline.
Eliot Moss wrote:
> echo -n $(cygpath -aw foo) > /dev/clipboard?
Gary, I was hoping for a magic bullet code idiom so that I don't have
to haul around a growing .alias.bash file. But I think your solution
might be the only one that significantly cuts down on the typing.
Jim, I think you're right. cygpath could benefit a lot from a -n
switch to suppress the new line. From google, however, it's actually
just li'l olde me that would benefit as no one else seems to have the
want for it. So I can see why such a switch has never been developed.
It's probably only needed for cygwin users, as it is the *unixy crowd
that uses both Windows & *nix at the same time.
Eliot, your solution takes 2 characters less than mine. If I want to
live without spaces aroud the "$(" and the ")". Which I suppose I
could do, for 2 characters..... I'm a bit enamoured of the linear
simplicity of my original pipeline, though. Appreciate the other
perspective, though.
Thank you all.
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list