LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 01: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, 01:22 AM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
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 01:31 AM. Reason: Typos, grammer, too many words...
 
Old 02-01-2014, 01: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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:04 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