- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: To read the 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
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
тАО03-25-2007 11:10 PM
тАО03-25-2007 11:10 PM
I have variable set:
LV=`vgdisplay -v vg00|awk '{if (/LV Name/) {split($3,a,/\//);printf "%s ",a[4]}}
'`
echo $LV
The output looks like that:
lvol1 lvol2 lvol3 lvol4 lvol5 lvol6 lvol7 lvol8
I nead to read the variable contex, character by character so I can eventualy separate all names of lvols and count them.
Perhaps there is a simplier method to count the hov many separate words are there?
Regards
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2007 11:17 PM
- Tags:
- for loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2007 11:17 PM
тАО03-25-2007 11:17 PM
Re: To read the variable
how about :
echo $LV | wc -w
see "man wc"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2007 11:41 PM
тАО03-25-2007 11:41 PM
Re: To read the variable
you can use wc command to do it with the switch -w.
so in your script, add this line;
echo $LV | wc -m
From wc man;
-m Counts characters
HTH,
Prabu.S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2007 12:04 AM
тАО03-26-2007 12:04 AM
Re: To read the variable
Based upon your questions, and without disrespect, you might find this shell overview helpful:
http://docs.hp.com/en/B2355-90046/B2355-90046.pdf
I would choose the Poxix shell since this is the HP-UX standard. It aligns closely to the Korn shell and Bash (in the Linux world) is another cousin.
A good site for shell scripts and techniques is also:
http://www.shelldorado.com/
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2007 01:23 AM
тАО03-26-2007 01:23 AM
Re: To read the variable
but because no one mentioned the use of an array in this context.
You could slightly modify your assignment to
e.g.
# set -A LV $(vgdisplay -v vg00|awk '/LV Name/{split($3,a,/\//);print a[4]}')
# echo ${#LV[*]}
10
- Tags:
- ARRAY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2007 01:32 AM
тАО03-26-2007 01:32 AM