- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- modify string into 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
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
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
тАО10-06-2005 09:34 AM
тАО10-06-2005 09:34 AM
How can I modify certain string which is into a file? (using just a command line statament).
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-06-2005 09:57 AM
тАО10-06-2005 09:57 AM
Solutionsed s/search_string/replacement_string file
sed s/hello/goodbye myfile > myfile2
You can then rename or move the new file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-06-2005 05:55 PM
тАО10-06-2005 05:55 PM
Re: modify string into file
use sed or awk command scripts.
you can also do string replacement using perl scripts.
Regards,
Gopi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-06-2005 06:44 PM
тАО10-06-2005 06:44 PM
Re: modify string into file
# Example:
file1:
hi
bye
# perl -pi -e 's/hi/first/g' file1
file1:
first
bye
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-06-2005 11:45 PM
тАО10-06-2005 11:45 PM
Re: modify string into file
perl -pi -e 's/
-p -> assumes the following loop around your script. while (<>) {
# your script goes here
} continue {
print or die "-p destination: $!\n";
}
-i -> specifies that files processed by the <> construct are to be edited in-place
-e -> Specifies a line of script.
More details are in the man page.Hope it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2005 04:27 AM
тАО10-07-2005 04:27 AM
Re: modify string into file
Create the script called script.vi:
^[:%s/string/replacement_string/g
^[:wq
The ^[: is created pressing CTRL+v and ENTER.
Then run
vi -s script.vi file_to_modify
The modifications will be done directly in the file.