- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How can I reduce count value in shell scriptin...
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
05-25-2006 11:15 PM
05-25-2006 11:15 PM
How can I reduce count value in shell scripting
Please advice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2006 11:21 PM
05-25-2006 11:21 PM
Re: How can I reduce count value in shell scripting
man expr
a=10
a=`expr $a - 1`
echo $a
9
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2006 11:26 PM
05-25-2006 11:26 PM
Re: How can I reduce count value in shell scripting
Using the shell's arithmetic:
# X=10;X=$((X - 1));echo ${X}
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2006 11:27 PM
05-25-2006 11:27 PM
Re: How can I reduce count value in shell scripting
let MYVAR=$MYVAR-1
You can use normal math symbols in the arithmetic let statement:
let MYVAR=$MYVAR*3
let MYVAR=$VAR2-$VAR3+1
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2006 12:02 AM
05-26-2006 12:02 AM
Re: How can I reduce count value in shell scripting
echo $MYVAR - 1 | bc
If you want to store in a variable
result=$(echo $MYVAR - 1 | bc)
Regards,
Ninad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2006 12:02 AM
05-26-2006 12:02 AM
Re: How can I reduce count value in shell scripting
a++; increase by 1
a--; decrease by 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2006 12:10 AM
05-26-2006 12:10 AM
Re: How can I reduce count value in shell scripting
I'm missing this format:
typeset -i var=12
((var-=1))
print $var says 11
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2006 12:28 AM
05-26-2006 12:28 AM
Re: How can I reduce count value in shell scripting
--------------
#!/usr/bin/csh
@ a = 4
@ a--
echo "$a"
@ a += 2
echo "$a"
--------------
output:
3
5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2006 02:35 AM
05-26-2006 02:35 AM
Re: How can I reduce count value in shell scripting
(( MYVAR=MYVAR - 1 ))
or equivalent
let "MYVAR=MYVAR - 1"
Note that you don't need $ in front of variables names since the shell is doing the arithmetic calculations.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2006 03:25 AM
05-26-2006 03:25 AM