- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Pattern replacing
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
06-14-2007 04:33 PM
06-14-2007 04:33 PM
Thanks in advance
Regards
Thomas
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 07:30 PM
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 07:33 PM
06-14-2007 07:33 PM
Re: Pattern replacing
perl -pi -e 's/OLDPATTERN/NEWPATTERN/g' file1 file2 file3 ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 08:24 PM
06-14-2007 08:24 PM
Re: Pattern replacing
try this on a posix-shell:
sed s/oldpattern/newpattern/ file | tee file
After applying the sed command file should be contain the newpattern. But remember it is just a single line substitution.
Greetings
Karsten
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 08:33 PM
06-14-2007 08:33 PM
Re: Pattern replacing
The tee(1) is going to writing to the same file that sed(1) is reading.
- Tags:
- tee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 08:40 PM
06-14-2007 08:40 PM
Re: Pattern replacing
thats right- if you want to shorten the sed script a bit, you can of course remove the filename after the tee command.
sed ... | tee its enough.
Greetings
Karsten
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 08:58 PM
06-14-2007 08:58 PM
Re: Pattern replacing
I'm not sure of your point but my point was that you can't use tee(1). You must write to a new file. And if you remove the file name after tee(1), why use tee(1)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 09:16 PM
06-14-2007 09:16 PM
Re: Pattern replacing
Thanks for your quick response
Regards
Thomas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 09:18 PM
06-14-2007 09:18 PM
Re: Pattern replacing
hmm - it works fine for me in both ways. I do the sed with the file - and then reading the same file with more/cat. Everything is replaced in the same file without any redirection ( see man tee - the tee command transcribes the standard input to the standard output and makes copies in the files )
Greetings
Karsten
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 09:41 PM
06-14-2007 09:41 PM
Re: Pattern replacing
I'm suggesting it may not work depending on the size of the file and the size of the stdio buffers and how many chars you are inserting/deleting with sed. In general, writing to the file you're reading isn't a good idea. Especially by separate processes that don't know this is occurring.