- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Using regular expressions with sed
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
тАО09-16-2008 10:51 AM
тАО09-16-2008 10:51 AM
I'm trying to write a script that will remove a directory from the PATH environment variable.
I know the directory (MF_SE) but not which tree it's in (ie it could be under a users /home or in /usr/local or elsewhere.
So I'm trying to replace ":[a-z/]MF_SE[a-z/]:" by ":"
I tried the following without results:
sed -e 's|:\[a-z/\]MF_SE\[a-z/\]:|:|' path
...:/usr/lib/nis:/opt/sec_mgmt/spc/bin:/opt/ssh/bin:/opt/oracle/product/10g/bin:/home/boucherr/MF_SE_41/history/bin:.:/home/boucherr/bin:.
As you see, no warnings or errors but no change performed.
Can anyone shed light?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-16-2008 11:22 AM
тАО09-16-2008 11:22 AM
SolutionMe thinks you want to find a ':', any number of not-':', a slash, the directory name, any number of not-':, and a ':'.
As in:
PATH=$( echo $PATH | sed -e 's|:[^:]*/MF_SE[^:]*:|:|' )
hth,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2008 05:25 AM
тАО09-17-2008 05:25 AM
Re: Using regular expressions with sed
I had made some corrections to mt original attempt and got it working with an uppercase identification string but could not get results with a lowercase string.
I didn't know about the "not" character.
Where is this documented?
I checked the man pages for sed, vi, regexp and I didn't spot it.
Many thanks
RayB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2008 05:43 AM
тАО09-17-2008 05:43 AM
Re: Using regular expressions with sed
> I didn't know about the "not" character.
Where is this documented?
See 'man 5 regexp' in the discussion of "non-matching list".
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2008 05:48 AM
тАО09-17-2008 05:48 AM
Re: Using regular expressions with sed
man sed --> man regexp
man 5 regexp --->
" ^ The circumflex is special when used as the first character of an entire RE (see Expression Anchoring) or as the first character of a bracket expression."
" non-matching list
A non-matching list expression begins with a circumflex (^), and specifies a list that matches any character or collating element except newline and the characters represented in the list."
hth,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2008 06:07 AM
тАО09-17-2008 06:07 AM
Re: Using regular expressions with sed
I had used "man regexp".
Thanks again
RayB