- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Increment a variable name
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
тАО01-30-2009 06:35 AM
тАО01-30-2009 06:35 AM
simple example
count = 0
count=`expr $count + 1`
# 1st time thru count would be equal to 1
tm$count="69"
echo $tm1
$tm1 fails and does not exist
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-30-2009 06:40 AM
тАО01-30-2009 06:40 AM
Re: Increment a variable name
More effieiently, since using 'expr' spawns another process, use the shell's arithmetic abilities:
# X=1
# echo ${X{
1
X X=$((X+1))
# echo ${X}
2
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-30-2009 06:42 AM
тАО01-30-2009 06:42 AM
Re: Increment a variable name
Sorry, there's a typo. My post should be:
# X=1
# echo ${X}
1
X X=$((X+1))
# echo ${X}
2
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-30-2009 06:50 AM
тАО01-30-2009 06:50 AM
SolutionI think you missed what he's looking for,
he appears to want to generate named variables in the form of
x1, x2 , x3...x
something along the lines of:
typeset -i cnt
cnt=0
eval tm$cnt=a
cnt=$cnt+1
eval tm$cnt=b
echo $tm0 $tm1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-30-2009 07:01 AM
тАО01-30-2009 07:01 AM
Re: Increment a variable name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-30-2009 07:37 AM
тАО01-30-2009 07:37 AM