LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-27-2009, 07:22 AM   #1
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,499
Blog Entries: 2

Rep: Reputation: 68
what is the purpose of $"string" in bash ?


Hi !

What is the purpose of that '$' in front of an string, like in
Code:
echo $"usage: $0"
in bash scripts ?

You can see it all around in scripts at /etc/init.d but I was not able to figure out what is its purpose, neither found references to it in bash man page....


The only reference to it is indirect:
from bash man page:
Code:
extquote
        If  set,  $'string'  and  $"string"  quoting is performed within ${parameter} expansions enclosed in double quotes.
        This option is enabled by default.
 
Old 10-27-2009, 07:41 AM   #2
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
I guess you didn't look hard enough. It's in the man-page fairly near the beginning, however, as the bash man-page is so big and ugly, I'll forgive you this once.


Code:
 Words  of the form $'string' are treated specially.  The word expands to string, with back-
       slash-escaped characters replaced as specified by the ANSI C  standard.   Backslash  escape
       sequences, if present, are decoded as follows:
              \a     alert (bell)
              \b     backspace
              \e     an escape character
              \f     form feed
              \n     new line
              \r     carriage return
              \t     horizontal tab
              \v     vertical tab
              \\     backslash
              \'     single quote
              \nnn   the eight-bit character whose value is the octal value nnn (one to three dig-
                     its)
              \xHH   the eight-bit character whose value is the hexadecimal value HH (one  or  two
                     hex digits)
              \cx    a control-x character

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

       A double-quoted string preceded by a dollar sign ($) will cause the string to be translated
       according to the current locale.  If the current locale is C or POSIX, the dollar  sign  is
       ignored.  If the string is translated and replaced, the replacement is double-quoted.
 
Old 10-27-2009, 10:29 AM   #3
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,499

Original Poster
Blog Entries: 2

Rep: Reputation: 68
Thank you very much, dear GazL, to being a so nice and understanding Guru !

cheers,
 
  


Reply

Tags
bash



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl - Can't use string ("html") as an ARRAY ref while "strict refs" OldGaf Programming 9 08-11-2009 11:14 AM
Bash variable problem: cURL -b parameter (string form e.g. "name=value;n2=v2") sithemac Other *NIX 3 07-09-2008 06:15 PM
"Permission denied" and "recursive directory loop" when searching for string in files mack1e Linux - Newbie 5 06-12-2008 07:38 AM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
bash cripting function to "identify" any char in a string? minike Programming 8 02-01-2006 09:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration