LinuxQuestions.org
Support LQ: Use code LQCO20 and save 20% on CrossOver Office
Go Back   LinuxQuestions.org > Forums > Linux > Linux - General
User Name
Password
Linux - General This 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

Tags used in this thread
Popular LQ Tags

Reply
 
Thread Tools
Old 10-27-2009, 08:22 AM   #1
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,285
Blog Entries: 1
Thanked: 5
what is the purpose of $"string" in bash ?


[Log in to get rid of this advertisement]
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.
linuxfedora marozsas is offline  
Tag This Post
Reply With Quote
Old 10-27-2009, 08:41 AM   #2
GazL
Member
 
Registered: May 2008
Location: England.
Posts: 879
Thanked: 78
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.
linux GazL is online now     Reply With Quote
Old 10-27-2009, 11:29 AM   #3
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,285
Blog Entries: 1
Thanked: 5

Original Poster
Thank you very much, dear GazL, to being a so nice and understanding Guru !

cheers,
linuxfedora marozsas is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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 Off
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 12:14 PM
Bash variable problem: cURL -b parameter (string form e.g. "name=value;n2=v2") sithemac Other *NIX 3 07-09-2008 07:15 PM
"Permission denied" and "recursive directory loop" when searching for string in files mack1e Linux - Newbie 5 06-12-2008 08:38 AM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 11:18 PM
bash cripting function to "identify" any char in a string? minike Programming 8 02-01-2006 10:45 AM


All times are GMT -5. The time now is 08:33 AM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration