Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Strip a Carriage-Return from a string/variable



Matt Wozniski wrote in 
news:17393e3e0908251621u7423cb1bk10c767b5b9ed19ef@xxxxxxxxxxxxxx:


>> And anywhere in the variable/any number of times?
> 
> Then you'd go with what Frank Terbeck suggested.
> 
> % foo=$'bar\r\rbaz'
> % print $foo | xxd
> 0000000: 6261 720d 0d62 617a 0a                   bar..baz.
> % print ${foo//$'\r'/_} | xxd
> 0000000: 6261 725f 5f62 617a 0a                   bar__baz.
> 
> ~Matt
> 
> 
Whoops thanks Frank & Matt.
On my cygwin had to use \n

foo=$'bar\n\nbaz'

print $foo
bar

baz
>
>print ${foo//$'\n'}
barbaz


-- 
zzapper




Messages sorted by: Reverse Date, Date, Thread, Author