If you have a text file and we need to search and replace a word within itWith another word or phrase on Windows we have many solutions. We can use NotepadThe, WordPadCPC or microsoft Word Office (This would be the most common)
Order "search & replace"In large text files is a problem Windows. Experts say it as a text file over 50 MB in which we replaced the word with "Replace All"Becomes a problem for an operating system Windows 7Whether the file was opened in Notepad, WordPad or in another text editor.
The problem becomes much simpler when it comes to Linux. With a simple commandline (Bash command) can search and replace a word within a file (file can be.doc,.docx,. Txt,. Sql, etc format containing text) in a very short time. Much shorter than on Windows.
Find and replace text within a file using the command "sit".
Let's say you have a text file (Document.txt) Word "a B C"We want to replace it with"xyz. "Command line that can replace the word will be as follows:
sed-ie 's / abc / xyz / g' Document.txt
When you execute the command, the condition is that we are in the folder that was Document.txt. If we are not in your Documents folder, but know the "way" it, the command line would be:
sed-ie 's / abc / xyz / g' / var / www / Document.txt
Where "/ var / www /" is the folder in which the file is Document.txt.
After execution of the command line option "I" will create a backup file identical to the original, but the extension which will add the letter "e". In our case, the document will be backup Document.txt.
-I [SUFFIX],-in-place [= SUFFIX] edit files in place (Makes backup if extension Supplied)
's Script-expression = script: add the script to the commands to be executed.
The command "find & replace" not only applies to files. Txt. You can replace words inside any file that contains text. Even Database files MySQL (. SQL)
Stealth Settings – Find & Replace Inside a Text File (Linux Bash Command Line).