Search and replace can be done from linux terminal in many ways. Here's another alternative blog entry on doing string replacements, search and replace via terminal using replace linux command.
Man replace:
The replace utility program changes strings in place in files or on the standard input.
Invoke replace in one of the following ways:
shell> replace from to [from to] ... -- file [file] ...
shell> replace from to [from to] ... < file
from represents a string to look for and to represents its replacement. There can be one or more pairs of strings.
Use the -- option to indicate where the string-replacement list ends and the filenames begin. In this case, any file named on the
command line is modified in place, so you may want to make a copy of the original before converting it. replace prints a message
indicating which of the input files it actually modifies.
If the -- option is not given, replace reads the standard input and writes to the standard output.
replace uses a finite state machine to match longer strings first. It can be used to swap strings. For example, the following command
swaps a and b in the given files, file1 and file2:
shell> replace a b b a -- file1 file2 ...
If you wish to see more of replace description, see replace man page or visit http://dev.mysql.com/doc/.
Here's a sample of replace command tool created and part of MySQL server package.
# cat testfile.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
paper is not paper
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# replace paper clouds -- testfile.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
testfile.txt converted
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# cat testfile.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clouds is not clouds
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HTH
Subscription
Categories
- HowTos (612)
- Linux Devices (40)
- Linux Diggs (620)
- Linux News (1541)
- Linux Videos (24)
Recent Posts
Blog Archive
-
▼
2007
(340)
-
▼
November
(39)
- HowTo: Strip directory path and filename suffix
- HowTo: Get the Filename Extension Only
- Tailf - watch the linux log file grows
- Fedora 8 with Enlightenment Window Manager
- HowTo: ScreenCasts & Desktop Records via Istanbul
- HowTo: Record Desktop Session via Byzanz
- Linux Scorched 3D Tank Game
- Linux Atomic Battle Tank Game
- HowTo: Display a Tree of Linux Processes
- Howto: 3 Easy Install Steps of Microsoft Fonts in ...
- Howto: Convert PDF to HTML/XML/PNG in Linux
- Livna Repository on Fedora 8
- Linux Action Flight Simulator Game
- Splitting and Merging Multiple Linux Files
- Sort Nth Position of Nth Column of a File in Linux
- Stop, Pause, and Continue A Linux Process
- File Creation without File Opening in Linux
- Concatenate Multiple Files in Linux
- Renaming Files in Linux
- Linux Power Consumption Analysis Tool
- Tail and Head Few Lines of Text Files
- Three Easy Steps for Opera on Fedora 8
- Alternative Search and Replace Tool
- Display Lines Beginning with a Given String
- Spell Check Files via Terminal - Install Howto
- Display Linux Session Jobs
- Get Linux Disk Space and Usage
- Change Linux RunLevels Howto
- Audacious - Install Howto
- Amarok - Howto Install
- Sun Java on Fedora 8 Install HowTo
- My Fedora 8 Diary
- Chikka on Kopete Messenger Howto
- Linux Files and Folders Local Copying
- Linux folders and directories recursive removal
- MailX - Mail Facility via Terminal
- Time zone values interpretation
- Retrieving Linux Standard Base and Distro Information
- Fedora Firstboot
-
▼
November
(39)
Tuesday, November 20, 2007
Alternative Search and Replace Tool
Subscribe to:
Post Comments (Atom)
ILoveTux - howtos and news | About | Contact | TOS | Policy
0 comments:
Post a Comment