From: Jean-Rene David on 28 Mar 2010 16:13 * Janis Papanagnou [2010.03.27 09:02]: > Cat 22 wrote: >> In a bash script I have a variable called recs >> recs="this is line 1\r\nThis is line 2\r\nthis is line3\r\n" > > In your string a sequence of \r\n is four characters, \ r \ and n. > Below I see ^M (ctrl-M) and you're speaking of OD OA sequences, so I > assume you rather have the equivalent of > > recs=$'this is line 1\r\nThis is line 2\r\nthis is line3\r\n' I had forgotten about the $'foo\nbar\n' syntax. What is it called again? I didn't see it in the 'Parameter Expansion' section of the Posix standard. In fact I found: 2.6 Word Expansions [...] The '$' character is used to introduce parameter expansion, command substitution, or arithmetic evaluation. If an unquoted '$' is followed by a character that is either not numeric, the name of one of the special parameters (see Special Parameters), a valid first character of a variable name, a left curly brace ( '{' ) or a left parenthesis, the result is unspecified. Which left me perplexed. Is that notation not standard? -- JR
|
Pages: 1 Prev: shell Next: $'foo\nbar\n' syntax (was: Re: bash printing variable withnewlines) |