Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Linux by (18.4k points)

An answer to this intellipaat question mentions that $'\n' is a special syntax "is not available in every shell".

I wonder what does the syntax means?

1 Answer

0 votes
by (36.8k points)

See below the bash man page's QUOTING section:

   Words of the form $'string' are treated specially.  The word  expands  to

   string,  with  backslash-escaped  characters replaced as specified by the

   ANSI C standard.  Backslash escape sequences, if present, are decoded  as

   follows:

...

              \n     new line

...

The expanded result is single-quoted as if the dollar sign had not been present.

This syntax is not part of the official Unix Bourne shell. It might be specific to bash.

To know about Linux join the Linux training

Related questions

0 votes
1 answer
asked Dec 13, 2020 in Linux by blackindya (18.4k points)
0 votes
1 answer
asked Nov 29, 2020 in Linux by blackindya (18.4k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...