GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: deleting a string and string substitution
Operating System - HP-UX
1849053
Members
6266
Online
104041
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
07-08-2004 04:52 AM
07-08-2004 04:52 AM
Hello,
First question:
A file has the following in several lines
/var/tmp/logs/C/dat
sed 's/logs//g' replaces 'logs' with '/' which is not what I want. What I want is to remove logs so that I end up with a directory structure of /var/tmp/C/dat withing the file.
How would you do it using sed? perl? others?
Second question:
A file has several "core" lines, how would you substitute "hostname:/tmp/apps/XYZ" using sed? perl? others?
Thanks,
Jimmy
First question:
A file has the following in several lines
/var/tmp/logs/C/dat
sed 's/logs//g' replaces 'logs' with '/' which is not what I want. What I want is to remove logs so that I end up with a directory structure of /var/tmp/C/dat withing the file.
How would you do it using sed? perl? others?
Second question:
A file has several "core" lines, how would you substitute "hostname:/tmp/apps/XYZ" using sed? perl? others?
Thanks,
Jimmy
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2004 04:56 AM
07-08-2004 04:56 AM
Re: deleting a string and string substitution
Hi Jimmy,
Try this.
sed 's/logs\///g' oldfile > newfile.
Sundar.
Try this.
sed 's/logs\///g' oldfile > newfile.
Sundar.
Learn What to do ,How to do and more importantly When to do ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2004 04:59 AM
07-08-2004 04:59 AM
Solution
Hi Jimmy,
You would need to remove the entire string '/logs' or 'logs/'
sed 's/\/logs//g'
I would do something like this to replace core file if I understand your second question correctly
HOST=$(hostname)
sed 's/core/'$HOST'\:\/tmp\/apps\/XYZ/g'
sed has it's own limitations though.
-Sri
You would need to remove the entire string '/logs' or 'logs/'
sed 's/\/logs//g'
I would do something like this to replace core file if I understand your second question correctly
HOST=$(hostname)
sed 's/core/'$HOST'\:\/tmp\/apps\/XYZ/g'
sed has it's own limitations though.
-Sri
You may be disappointed if you fail, but you are doomed if you don't try
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2004 05:13 AM
07-08-2004 05:13 AM
Re: deleting a string and string substitution
Hi
A possible solution for your first question may be something like this:
sed 's?/logs??'
Could you please clarify you second question ? You want to substitute
hostname:/tmp/apps/XYZ with what ?
A possible solution for your first question may be something like this:
sed 's?/logs??'
Could you please clarify you second question ? You want to substitute
hostname:/tmp/apps/XYZ with what ?
Entities are not to be multiplied beyond necessity - RTFM
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2026 Hewlett Packard Enterprise Development LP