linux - Bash echo with an $ character outside the string -


can explain difference between

echo $"starting $cmd"  

and

echo "string $cmd" 

they seem same.

look quoting section of bash man page:

words of form $'string' treated specially. word expands string, backslash- escaped characters replaced specified ansi c standard. backslash escape sequences, if present, decoded follows:

  • \a alert (bell)
  • \b backspace
  • \e escape character
  • \f form feed
  • \n new line
  • \r carriage return
  • \t horizontal tab
  • \v vertical tab
  • \ backslash
  • \' single quote
  • \nnn eight-bit character value octal value nnn (one 3 digits)
  • \xhh eight-bit character value hexadecimal value hh (one or 2 hex digits)
  • \cx control-x character

the expanded result single-quoted, if dollar sign had not been present.

and note follow description double quoted strings preceded $ ($"string"):

a double-quoted string preceded dollar sign ($) cause string translated according current locale. if current locale c or posix, dollar sign ignored. if string translated , replaced, replacement double-quoted.


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -