- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: what does the mean about $
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-03-2005 11:27 PM
тАО06-03-2005 11:27 PM
I often see the symbol "$" in some script:
PATH=${ORACLE_HOME}/bin:/sbin:/usr/bin:/usr/sbin:/etc:/bin
what does the mean and what function about the $ ?
thanks for your help
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-03-2005 11:28 PM
тАО06-03-2005 11:28 PM
Re: what does the mean about $
Stf ;-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-03-2005 11:34 PM
тАО06-03-2005 11:34 PM
Re: what does the mean about $
$ is a variable name identification used in shell.
in shell: just VAR means list of characters. $VAR means variable
if you say echo VAR, it will just print VAR. whereas if you say echo $VAR, it will print the contents of the variable VAR.
I guess i explained more than enough
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-04-2005 04:04 AM
тАО06-04-2005 04:04 AM
Solution1 - variable concatination.
${ORACLE_HOME} this will evaluate that variable, say /home/oracle
${ORACLE_HOME}XXX This will evaluate ${ORACLE_HOME} & ADD XXX so, /home/oracleXXXX.
${ORACLE_HOME}/${MY_SCRIPTS} would concatanate the whole string to say, /home/Oracle/scripts/bin (assuming MY_SCRIPTS=scripts/bin).
The reason for the curly brackets ${} is to explicitly define the variable. e.g. you COULD have used $ORACLE_HOMEXXX . this would NOT work as there is no (well it is unlikley) to be a varable called "ORACLE_HOMEXXX". The backets allow explicit variable concatination.
2 - variable substitution.
Sometimes you want to read the result of a command into a variable e.g.
$TDAY --> todays date.
This can be done like so
export TDAY = $(date)
Now $TDAY has todays date in it. In effect the $(..cmd..) executes the command and presents it to the shell as a variable, (as opposed to standard error or standard out) so the following is equally valid (but trivial)
echo $(date)
I fully admit that the above is trivial, but it can be useful in more complex scripts. Imagine that you wanted to print out all the logical volumes you have in vg01. You can list all the logical volume names using vgdisplay -v vg01|grep "LV Name"; but this is not enough as you want ALL the info for each LV (without doing each one manually)... so
for lv in $( /etc/vgdispalay -v vg01| perl -ane 'if (m/LV Name/) { print "$F[2] "})
do
/etc/lvdisplay $lv
done
IF you were not allowed to use the structure $( ..cmd.. ) then the only other way of doing this would be to output the above commands to a file & read it back into a for;do;done loop. This would be slower as it needs to write the data to disks as opposed to doing the whole operation in memory.
Anyway.. the $VAR; ${VAR}; and $( ..cmd.. ) structures are very useful..
Regards
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-06-2005 07:07 AM
тАО06-06-2005 07:07 AM
Re: what does the mean about $
# ORACLE_HOME=/opt/oracle/9.2.0
now use this value in other variables or simply echo it at the command line
#PATH=$ORACLE_HOME/bin:/sbin:/usr/sbin:/etc:/bin
#echo $PATH
/opt/oracle/9.2.0/bin:/sbin:/usr/sbin:/etc:/bin
cheers!