This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Direct/efficient way to chop off trailing \n
- From: Paul.Domaskis <Paul dot Domaskis at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Wed, 1 Oct 2014 23:10:50 +0000 (UTC)
- Subject: Re: Direct/efficient way to chop off trailing \n
- Authentication-results: sourceware.org; auth=none
- References: <loom dot 20141001T235147-60 at post dot gmane dot org>
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