- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- 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
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
тАО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