- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Editing a file using '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
Forums
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
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
тАО02-26-2003 08:52 AM
тАО02-26-2003 08:52 AM
1. Remove all / from file
2. Remove all spaces that follow =
3. Remove all spaces that follow +
4. Remove all spaces that follow :
5. Reduce remaining multiple spaces on lines to 1 space
6. Remove blank lines from file
7. Change all occurances of \ to spaces
Hope you can help!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2003 09:42 AM
тАО02-26-2003 09:42 AM
Solutionsed "s/= /=/g" file > file.tmp;mv file.tmp file
sed "s/+ /+/g" file > file.tmp;mv file.tmp file
sed "s/: /:/g" file > file.tmp;mv file.tmp file
sed "s/\w+/\w/g" file > file.tmp;mv file.tmp file
sed "s/\\/ /g" file > file.tmp;mv file.tmp file
Good Luck.
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2003 09:43 AM
тАО02-26-2003 09:43 AM
Re: Editing a file using 'sed'
1. # sed -e 's%/%%'g
2. # sed -e 's%= %=%'g
3. # sed -e 's%= %+%'g
4. # sed -e 's%= %:%'g
5. # sed 's/ */ /g' #...that 2-spaces before the asterisk character.
6. # sed '/^$/d
7. # sed -e 's%\\% %'g
Note that doing step-5 first simplifies the remaining edits. In fact, depending on your objective, the point at which you do step-7 might differ too.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2003 09:51 AM
тАО02-26-2003 09:51 AM
Re: Editing a file using 'sed'
Oops, I fat-fingered my own cut-and-paste for #3 and #4 (which is obvious if you look at my original post!):
3. # sed -e 's%+ %+%'g
4. # sed -e 's%: %:%'g
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2003 10:02 AM
тАО02-26-2003 10:02 AM
Re: Editing a file using 'sed'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2003 01:12 PM
тАО02-26-2003 01:12 PM
Re: Editing a file using 'sed'
This will delete all spaces and tabs followed by =,+ and : along with the others you mentioned. 'data' is your input file.
sed -e 's/\///g' \
-e 's/=[ ]*/=/g' \ #[
-e 's/+[ ]*/+/g' \ #[
-e 's/:[ ]*/:/g' \ #[
-e 's/ */ /g' \ #/
-e '/^ *$/d' \ #/^
-e 's/\\//g' data
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2003 09:19 AM
тАО02-27-2003 09:19 AM
Re: Editing a file using 'sed'
-e 's/\///g'
-e '/./!d'
-e 's/ */ /g'
-e 's/\\/ /g' test.txt > new.txt