- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Regular expression help
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
Forums
Discussions
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
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
12-16-2007 04:48 PM
12-16-2007 04:48 PM
Regular expression help
I have an XML configuration file that has a line with the following format:
I'm trying to grab the "cluster" portion of the string. However, the id and ordered parameters can be reversed randomly so it's not as simple as I'd assumed at first.
Jeff Traigle
- Tags:
- regex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2007 05:10 PM
12-16-2007 05:10 PM
Re: Regular expression help
You could just ignore the "ordered" part:
$ sed -e 's/group id="\(.*\)" /\1/' file
This should work as long as "true" doesn't have a space after it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2007 05:16 PM
12-16-2007 05:16 PM
Re: Regular expression help
$ sed -e 's/
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2007 05:35 PM
12-16-2007 05:35 PM
Re: Regular expression help
testfile contains:
With this command:
sed 's/.*id="\(.*_pkg\)".*/\1/' testfile
It returns:
cluster_pkg
cluster_pkg
I don't want the _pkg portion of the string either though.
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2007 05:38 PM
12-16-2007 05:38 PM
Re: Regular expression help
Command looks like this:
sed 's/.*id="\(.*\)_pkg".*/\1/' testfile
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2007 05:39 PM
12-16-2007 05:39 PM
Re: Regular expression help
Ah, that makes it easier.
$ sed 's/.*id="\(.*\)_pkg".*/\1/' testfile