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

Re: test for newline in a variable--unexpected results sometimes



On Sun, Sep 16, 2018 at 08:44:33PM +0000, Daniel Shahaf wrote:
> In this context, «\n» does not mean a newline; it means either the letter 'n',
> or the two-character sequence «\n», but I don't remember which.

Thanks! Problem solved.

> > cmd2="cd \ncd /sys/class/leds"
> 
> Ditto..  If you try «xxd <<<$cmd2» you'll see the variable's value contains the
> two-character sequence «\n».

I echoed it, and it turns out that echo itself turned all \n into real newlines.

-- 
Best regards,
lilydjwg



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