- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: word splitting in shell
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-25-2003 08:46 AM
03-25-2003 08:46 AM
I wrote a shell script like this
#!/bin/sh
lv=`bdf |grep /var/opt/nokia |awk '{print $1}'`
In the lv variable I will get some string like "/dev/vg01/lvol2", from this string i have get "vg01" to some other variable.
If is is silly, please don't laugh on me because i am new to shell programming (:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2003 08:53 AM
03-25-2003 08:53 AM
SolutionUse the seperator "FS" to achieve what you want. For ex., if you want to get only the Logical volume, you would do
bdf |grep /var/opt/nokia |awk '{print $1}'|awk '{FS="/";print $4}'
Use 'df' instead of 'bdf'. If your lvol name is too long, then you may not get what you want.
If you df, you should grep for the second column and then filerout what you want using the above logic.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2003 08:54 AM
03-25-2003 08:54 AM
Re: word splitting in shell
BTW, if you want to get 'vg01' out of it, you will use '{FS="/";print $3}'
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2003 08:54 AM
03-25-2003 08:54 AM
Re: word splitting in shell
Try this
bdf |grep /var/opt/nokia | cut -f 3 -d "/"
This should yield the VG name w/o having to awk. Of course, you could assign the output to a var.
HTH,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2003 08:55 AM
03-25-2003 08:55 AM
Re: word splitting in shell
'cut' will do here:
# VAR=`echo ${lv}}cut -f3 -d/`
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2003 08:59 AM
03-25-2003 08:59 AM
Re: word splitting in shell
bdf |grep /var/opt/nokia |awk '{FS="/";print $3}'
Robert-Jan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2003 09:11 AM
03-25-2003 09:11 AM
Re: word splitting in shell
vg=${lv#/dev/}&& vg=${vg%/*}
Best regards...
Dietmar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2003 07:26 AM
04-04-2003 07:26 AM
Re: word splitting in shell
Instead of print $1, use split($1, arg, "/"]);print arg[3]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2003 05:43 PM
04-15-2003 05:43 PM
Re: word splitting in shell
split works well, another way would be
lv=$(bdf | grep /var/opt/nokia | awk -F/ '{print $1}')
6 ways to skin a cat :o)