LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 05-23-2006, 03:00 PM   #1
car182
LQ Newbie
 
Registered: Apr 2006
Posts: 6

Rep: Reputation: 0
Cool command line edit -- global find/replace on text file w/o going into vi


Hi all,

I'm a newbie to the Linux world and I am looking for an easy way to edit a file.

Basically, I want to perform a global/replace inside of a text file without going into vi.

I know how to go into vi and perform a global find/replace, but I want to do this in the shell (command line), not in vi -- that way I can do it nice a quick when I change configuration files.

Any suggestions? Thanks in advance.

Regards
car182
 
Old 05-23-2006, 03:06 PM   #2
reddazz
Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 73
Take a look at the sed command.
 
Old 05-23-2006, 10:51 PM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,251

Rep: Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025
eg:
sed -i -e 's/DROP TABLE/DROP TABLE IF EXISTS/' ClientInfo_audit.sql
ie replace 1st string with 2nd string in file(s)
 
Old 05-23-2006, 11:31 PM   #4
cs-cam
Senior Member
 
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,544
Blog Entries: 4

Rep: Reputation: 56
See my sig. 'Nuff said.
 
Old 05-25-2006, 05:42 PM   #5
car182
LQ Newbie
 
Registered: Apr 2006
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks

Thanks everyone for your responses
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and replace text in multiple file Bad_Bob Linux - Software 9 05-08-2008 02:31 AM
Python: find defined text string in a file, and replace the whole line Dark Carnival Programming 6 05-22-2007 06:02 AM
SED - replace text in file on specific line 3saul Linux - Software 1 03-04-2006 07:01 PM
Can't find edit grub.conf when im in command line. izac5 Linux - Newbie 7 11-16-2004 04:24 PM
find and replace in files from command line dexter_modem Linux - General 4 06-10-2003 11:27 AM


All times are GMT -5. The time now is 08:44 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration