LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-01-2014, 02:13 AM   #1
jone kim
Member
 
Registered: Apr 2010
Posts: 185

Rep: Reputation: 16
Exclamation declaring variables


1. What is the difference between $variable and ${variable}?
 
Old 02-01-2014, 02:22 AM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_10{.0|.1|.2}
Posts: 3,880
Blog Entries: 1

Rep: Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998
Assuming you mean in shell scripting:

Quick answer - there is no difference.

So why use one or the other? Using the ${...} version allows you to embed variables within strings, separating the variable from surrounding text.

Bash also allows some string manipulations inside the brackets.

Last edited by astrogeek; 02-01-2014 at 02:31 AM. Reason: Typos, grammer, too many words...
 
Old 02-01-2014, 02:58 AM   #3
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Following doc will also help: http://mywiki.wooledge.org/BashFAQ/082
 
  


Reply

Tags
variable


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
Declaring variables overhead PinoyAko Programming 5 05-15-2011 08:58 PM
Declaring variables in external and internal RAM VGM Programming 1 03-25-2010 05:37 PM
repetition and variables : declaring and assigning technomeister Programming 5 02-12-2010 11:23 AM
Another way of declaring variables in bash zhjim Programming 7 05-11-2009 09:57 AM
difference between () and = when declaring variables nadroj Programming 1 06-28-2005 02:37 PM


All times are GMT -5. The time now is 12:18 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration