- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How do I add results of wc -l
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
03-13-2003 02:37 PM
03-13-2003 02:37 PM
.
I have a short program to see how many power supplies are in a Nike. I use cstm and put results in a file. From the file is use a simple instruction -
psa=$(cat file|grep -c "VSC A: OK"|wc -l)
.
when I'm done looking for VSC A, B, C - I'm trying to get a total number of power supplies, since the customer have several Mod 20 units.
I've tried several commands to try and total the power supplies, but the output keeps coming back as "+1+1+1 etc".
Does anyone know a simple way to add $psa $psb and $psc to get a total?
.
I'm very generous with the points. Promise.
.
Regards,
Paul Middleton
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2003 02:41 PM
03-13-2003 02:41 PM
Solutionviz
X=$((${A} + ${B} + ${C}))
or
X=$((${A} * 3 + 7))
You also have the ability to nest using ()'s. the key is
$(( )) -- it's equivalent to the let statement but is much cleaner.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2003 02:41 PM
03-13-2003 02:41 PM
Re: How do I add results of wc -l
Many ways to do it - here's one
(($total=$psa+$psb+$psc))
$total will now contain the sum.
Rgds,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2003 02:44 PM
03-13-2003 02:44 PM
Re: How do I add results of wc -l
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2003 02:49 PM
03-13-2003 02:49 PM
Re: How do I add results of wc -l
# cat tmp.sh
#!/usr/bin/ksh
psa=2
psb=3
psc=4
echo $(( $psa + $psb + $psc ))
# ./tmp.sh
9
Hope this helps...
Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2003 09:26 AM
03-14-2003 09:26 AM
Re: How do I add results of wc -l
After 28 years in the field with hardware repairs, going into a supervisor position and working with HP-UX scripts is harder than I thought.
.
Wait a minute - if I had thought about it, I wouldn't be doing it.
.
Regards, and thanks again,
Paul Middleton