- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- help editing file
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
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
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
03-21-2003 08:09 AM
03-21-2003 08:09 AM
There are a lot of lines, so I am looking for a single command that I can run once.
Another way to put it is that I want to go to the last non-blank character of each line of the file and replace everything after it with a ^.
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2003 08:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2003 08:15 AM
03-21-2003 08:15 AM
Re: help editing file
# sed -e 's/[ \t][ \t]*$/^/' filename
Note that you need to type a TAB character in place of the '\t'. HP's 'sed' doesn't understand the notation. Hence that's a SPACE and a TAB character within each of the brackets.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2003 08:16 AM
03-21-2003 08:16 AM
Re: help editing file
Do the following
sed 's/ /^/g' your_file > new_file
(it is 's/
Or vi the file and type in
:%s/ /^/g
If you have tabs, then you can use the following
sed 's/[ ]/^/g' your_file
> new_file
('s/[
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2003 08:30 AM
03-21-2003 08:30 AM
Re: help editing file
For future reference, I'm attaching the Handy One-Liners for Sed that I originally got from Princess Paula.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2003 08:32 AM
03-21-2003 08:32 AM
Re: help editing file
Robin and James. They did exactly what I needed. For anyone else that might read this in the future - you need to do a "> newfile" to put the changes into a new file, otherwise, it just scrolls across the screen.
Sri - These commands replace the spaces with ^ one for one - not just the ones at the end of the file as I wanted. Thanks for trying.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2003 01:00 AM
03-22-2003 01:00 AM
Re: help editing file
# perl -pi -e 's/\s+$/^/' file
If you are less confident, you can create a backup
# perl -pi.bkp -e 's/\s+$/^/' file
Enjoy, have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2003 12:58 AM
03-23-2003 12:58 AM
Re: help editing file
pc03:/tmp 503 $ banner help >xx
pc03:/tmp 504 $ perl -pi -e 's/\s+$/^/' xx
pc03:/tmp 505 $ cat xx
^^ XX XX^ X X^ X X^ X XX XX
XXX X XXXXXX^ XX X X X X X X^ X X XXXXXXX X X
X^ X X X X X X^ X X X X X X X^ XXX XXX
XXXXX XXXXX XXXXX^ X^ XXX
^pc03:/tmp 506 $ banner help >xx
pc03:/tmp 507 $ perl -pi -le 's/\s+$/^/' xx
pc03:/tmp 508 $ cat xx
^
^
XX XX^
X X^
X X^
X XX XXXXX X XXXXXX^
XX X X X X X X
X X XXXXXXX X X X
X X X X X X
X X X X X X X
XXX XXX XXXXX XXXXX XXXXX^
X^
XXX^
pc03:/tmp 509 $
So replacing -e with -le will help a lot here.
Enjoy, have FUN! H.Merijn [ Who thinks that this message will be near to unreadable due to the space compressing in the forum messages ]