Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Substituting newline on a string
- X-seq: zsh-users 12992
- From: Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Substituting newline on a string
- Date: Tue, 01 Jul 2008 19:43:19 +0200
- In-reply-to: <150460.34757.qm@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <150460.34757.qm@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
Javier Alvarado <quijotista@xxxxxxxxx>:
> I have a seemingly trivial problem that I have not be able to solve.
> How do I replace a newline in a string with somethinge else, like '
> ' (or better yet '\n')?
>
> I've tried
>
> cmd=${1/$/ /}
> cmd=${1/\n/ /}
> cmd=${1/\r/ /}
How about this?
[snip]
zsh% foo=$'bar\nbaz'
zsh% printf '%s\n' $foo
bar
baz
zsh% printf '%s\n' ${foo//$'\n'/\\n}
bar\nbaz
[snap]
Regards, Frank
--
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
-- RFC 1925
Messages sorted by:
Reverse Date,
Date,
Thread,
Author