This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Direct/efficient way to chop off trailing \n


On 10/01/2014 08:25 PM, Eliot Moss wrote:
> You could write my solution as:
> 
> echo -n `cygpath -aw foo`>/dev/clipboard

'echo -n' is not portable (in fact, you can disable it in bash, and it
may misbehave if cygpath outputs a leading - or contains any \); it's
better to use 'printf' for that purpose:

printf %s `cygpath -aw foo`>/dev/clipboard


> The echo solution has the good property that echo is
> a shell built-in and so does not require spawning
> another process.

The same is true of printf.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]