- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Variable of variable
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
Forums
Discussions
Discussions
Discussions
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
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
04-12-2004 10:44 PM
04-12-2004 10:44 PM
I want to use a for loop within a shell script to display the value of several variables, but I can't manage it. It shoul be something like that:
for VAR in VAR1 VAR2 VAR3 ; do
echo
done
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2004 10:50 PM
04-12-2004 10:50 PM
Re: Variable of variable
a=5
b=5
for var in a b
do
echo $var
done
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2004 11:02 PM
04-12-2004 11:02 PM
Re: Variable of variable
Post additional info pls. Can you give us an example of what VAR, VAR1, VAR2 and VAR3 could be and your anticipated result.
-denver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2004 11:03 PM
04-12-2004 11:03 PM
Re: Variable of variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2004 11:04 PM
04-12-2004 11:04 PM
Re: Variable of variable
you have the following setup in place
export KAPS=KAPILRAJ
export KK=KAPS
using KK , you want to get KAPILRAJ i.e. something like echo ${$KK} .. ?
you may try the following
echo $KK|awk '{print "echo","$"$0}' |ksh
Please make sure that all the variables are exported i.e. export VAR1 VAR2
Regds,
Kaps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2004 11:06 PM
04-12-2004 11:06 PM
Re: Variable of variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2004 11:12 PM
04-12-2004 11:12 PM
Re: Variable of variable
An echo $VAR will show the value only !!
Regds,
Kaps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2004 11:17 PM
04-12-2004 11:17 PM
Re: Variable of variable
a=abc
b=def
for var in $a $b
do
echo $var
done
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2004 11:18 PM
04-12-2004 11:18 PM
Re: Variable of variable
VAR2=this
VAR3=it
for VAR in $VAR1 $VAR2 $VAR3; do
echo $VAR
done
or??
VAR1=is
VAR2=this
VAR3=it
VAR="$VAR1 $VAR2 $VAR3"
echo $VAR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2004 11:21 PM
04-12-2004 11:21 PM
Re: Variable of variable
A="this is 1"
B="This is 2"
for i in "$A" "$B"
do
echo $i
done
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2004 11:26 PM
04-12-2004 11:26 PM
Re: Variable of variable
Note that quotes are essential if your variable values contain multiple words.
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2004 12:45 AM
04-13-2004 12:45 AM
Re: Variable of variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2004 02:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2004 03:11 AM
04-13-2004 03:11 AM