- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Help with sed!? (RTFF,RTFM I hear you cry.......)
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
Forums
Discussions
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
12-11-2001 12:55 AM
12-11-2001 12:55 AM
Quick question:-
Sed. I'm sure in my glory days, I used to use sed to do text replacement on files (nothing wrong so far)....but here's the clintcher.. without writing the stdout to another file or did I? - ie replacing something within a file without creating a new version via redirection of stout.
Any tips pointers warmly received as ever, even RTFM's although if I trawl another sed how-to I might explode.
Cheers,
-ChaZ-
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2001 02:38 AM
12-11-2001 02:38 AM
Re: Help with sed!? (RTFF,RTFM I hear you cry.......)
with sed you cannot do text replacement inline :(. you have to use perl
...BPK...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2001 04:23 AM
12-11-2001 04:23 AM
Re: Help with sed!? (RTFF,RTFM I hear you cry.......)
Without an intermediate file ... I don't think that's possible in a script. Closest I could get was
(sed 's/Hallo/hallo/' < file1 > /tmp/file1) && (cat /tmp/file1 > file1) && (rm -f /tmp/file1)
... which is not at all what you asked ...
Tom Geudens :-(
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2001 05:01 AM
12-11-2001 05:01 AM
Solutionfor small files under 16k:
sed -e "s/oldstr/newstr/g" filename|tee >filename
for larger files, cheat:
dd if=filename bs=3000000|sed -e "s/oldstr/newstr/g" > filename
of course adjust the "bs" (block size accordingly to input file size)
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2001 07:02 AM
12-11-2001 07:02 AM
Re: Help with sed!? (RTFF,RTFM I hear you cry.......)
Thanks again!
-ChaZ-
Ps. I'll dish the points when netscape is back upto speed!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2001 07:36 AM
12-11-2001 07:36 AM
Re: Help with sed!? (RTFF,RTFM I hear you cry.......)
You cannot do it with sed. SED is the "Stream" ED. If you want to replace 'in place' you'll have to pipe commands to ed, like this:
echo "1,$ s/oldstring/newstring
w /tmp/testfile
q" | ed /tmp/testfile
This will change oldstring by newstring on /tmp/newfile
Regards,
Paga
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2001 11:24 PM
12-11-2001 11:24 PM
Re: Help with sed!? (RTFF,RTFM I hear you cry.......)
i don't think you can do it with sed. but i solved this problem with ex:
ex file_to_edit << EOF
1,\$s/oldstring/newstring/
w
q
EOF
Hope this helps
Regards Stefan