Results 1 to 1 of 1
-
9th Feb 2012, 11:23 AM #1OPMemberWebsite's:
AVANETCO.COM AVAVPS.COMHow to change a string in a text file on a Linux server
So, you want an easy to to replace text in files, even multiple files, on a linux machine, from the command line.
How? - You ask? Easy.
Let me show you.
Let?s say you want to replace all instances of ?John? with ?Pete? in a file, called resume.txt
In a bash shell, run the following:
Code:
PHP Code:
PHP Code:replace John Pete ? resume.txt
Now, how about replacing all instance of ?/home/? with ?/home2/?? in all files located in /etc/? (let?s say you have moved the home folder)
Code:
PHP Code:
PHP Code:replace /home/ /home2/ ? /etc/*
Or, you want to update your DNS servers quickly, after moving your servers to a new domain. The old domain was mydomain.com & the new domain is ourdomain.com
Code:
PHP Code:
PHP Code:replace mydomain newdomain ? /var/named/*.db
Albert.Nawaro Reviewed by Albert.Nawaro on . How to change a string in a text file on a Linux server So, you want an easy to to replace text in files, even multiple files, on a linux machine, from the command line. How? - You ask? Easy. Let me show you. Let?s say you want to replace all instances of ?John? with ?Pete? in a file, called resume.txt In a bash shell, run the following: Code: PHP Code: replace John Pete ? resume.txt Rating: 5
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Change File MD5 on Windows Server 2008
By viruz99 in forum General DiscussionReplies: 5Last Post: 27th May 2011, 07:41 PM -
change VPS in linux
By iobit in forum Hosting DiscussionReplies: 0Last Post: 27th Feb 2011, 08:47 PM -
change VSP in linux
By iobit in forum Technical Help Desk SupportReplies: 0Last Post: 23rd Feb 2011, 06:26 AM -
Here Is the PSD- Just change The Text
By umang in forum Graphics AreaReplies: 2Last Post: 27th Sep 2010, 12:17 AM -
Change IP Address on a Linux Server
By BlaZe in forum Technical and Security TutorialsReplies: 0Last Post: 23rd Oct 2009, 05:50 AM
themaLeecher - leech and manage...
Version 5.03 released. Open older version (or...