LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-21-2010, 07:48 AM   #1
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
printf $"Hello $var\n" vs. printf "Hello $var\n" -- not a typo. What is it?


Searching search engines for something specifically about a dollar-sign in front of a string or variable is near impossible. And so far (still looking) the Greg's Wiki and various other Bash tutorials and things, are not showing this syntax. I'm sure it's somwehere, I just haven't found it yet.

Is there some reason why a dollar-sign is prepended to the front of a quoted string (which happens to contain a variable)? I have found that with either `echo` or `printf` there is no detectable difference between the output of the two.

Can someone explain, or point me to where is explained, this?

Thank you!
 
Old 10-21-2010, 08:16 AM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Wheezy (Fluxbox WM)
Posts: 1,363
Blog Entries: 52

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Quote:
Originally Posted by GrapefruiTgirl View Post
Is there some reason why a dollar-sign is prepended to the front of a quoted string
It is so that the string will be localized if possible (part of i18n).
 
1 members found this post helpful.
Old 10-21-2010, 08:21 AM   #3
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Original Poster
Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Ahhh! Thank you neonsignal.
 
  


Reply

Tags
dollar sign, locale, prepended, printf, quoted, string


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
printf( "Hello %s\n", "World" ) megacoder LinuxQuestions.org Member Intro 1 09-29-2010 11:16 AM
if [ "$VAR"="string" ] always testing TRUE JohnE1 Programming 2 08-05-2008 08:35 PM
Printf and a sort of "null character"? Possible? BlueSpirit Programming 26 05-02-2007 05:17 PM
c gurus: whats the diff? "var[]" and "*var"? kourama Programming 16 04-03-2007 10:28 AM
"printf" slow down benchmark result syseeker Programming 1 06-07-2006 05:55 AM


All times are GMT -5. The time now is 11:19 PM.

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
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration