Direct/efficient way to chop off trailing \n

Eric Blake eblake@redhat.com
Thu Oct 2 02:33:00 GMT 2014


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 539 bytes
Desc: OpenPGP digital signature
URL: <http://cygwin.com/pipermail/cygwin/attachments/20141002/bb4adc8f/attachment.sig>


More information about the Cygwin mailing list