- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- grep - how to exclude fields ?
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-26-2007 04:34 AM
тАО03-26-2007 04:34 AM
bdf |grep /stand
output:
/dev/vg00/lvol1 295024 59344 206176 22% /stand
I nead o exclude all but lvol1 and /stand
Can anyone help ?
Cheers
Solved! Go to Solution.
- Tags:
- grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2007 04:38 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2007 04:40 AM
тАО03-26-2007 04:40 AM
Re: grep - how to exclude fields ?
bdf | grep /stand | awk ' { print $1" "$NF}'
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2007 04:43 AM
тАО03-26-2007 04:43 AM
Re: grep - how to exclude fields ?
The simple way:
# bdf|grep -v -e /stand -e lvol1
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2007 05:46 AM
тАО03-26-2007 05:46 AM
Re: grep - how to exclude fields ?
No ifs or buts.
So grep needs help, typically awk or cut.
John K, shows a fine example of this helping.
However, why not let awk (or perl) do it all?
$ bdf | awk '/stand/ {print $1,$NF}'
Also, somehow I'm thinking this is not your end goal. What problem are you really trying to solve ?!
Regards,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2007 05:55 AM
тАО03-26-2007 05:55 AM
Re: grep - how to exclude fields ?
- Tags:
- bdfmegs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2007 06:05 AM
тАО03-26-2007 06:05 AM
Re: grep - how to exclude fields ?
lvol1 stand
run:
bdf | grep /stand | sed -e "s/\// /g" -e "s/ */ /g" | cut -d " " -f 4,9
Note: the first sed expression has a single space before the "/g", and the second one has *two spaces* after the "s/" and a single space before the "/g".
I'm guessing that since you know that /stand is in vg00 you're not interested in the whole /dev/vg00/lvol1 part of the string.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2007 06:39 AM
тАО03-26-2007 06:39 AM
Re: grep - how to exclude fields ?
An easier one than the previous posting would be:
> df | grep stand | cut -b -15,33-42
And actually
> df -n | grep stand
gets you pretty close to what you asked for w/o stream edits.
If you're wanting make sure to avoid the "bdf" line wrap problem indirectly mentioned in a previous posting use the contents /etc/mnttab instead:
> grep stand /etc/mnttab | cut -d "/" -f 4,5 | cut -d " " -f 1,2
gives:
lvol1 /stand