In this article we are going to shows how to use replace command in Ubuntu Linux. If you want to learn about replace command in Ubuntu Linux with Examples then this post is ideal for you.
In Linux computing, replace is a command line utility that is used to replace or change strings of text in files or the standard input.
Linux is an operating system, like Windows OS, iOS, and Mac OS. It is one of the most popular operating system on the planet, Android is also powered by Linux OS(operating system).
Linux OS(operating system) is also distributed under an open source license. Open source following these points :
- Freely to run the program, for any purpose.
- Free to study how the program works.
- Freely to re-distribute copies so you can help your friends.
- Free to distribute copies of your modified versions to others.
Ubuntu is a Linux Operating System based on Debian and mostly composed of non-profit(free) and open-source software. It is a complete Linux operating system that compatible with desktops, laptops, server and other devices. Ubuntu is Open Source so it is freely available for both community and professional support.
if you are a learner and looking for a Linux distribution for Learning then Ubuntu Linux Operating System is best for you as a beginning.
How to Use Replace command in Ubuntu Linux
In the Ubuntu Linux, the basic syntax of the replace command is show as below:
replace [-?svIV] from to from to ... -- [files]
replace [-?svIV] from to from to ... < fromfile > tofile
Options Of Replace Command
tofile | Replace tofile with the name of the new output file. |
-?, -I | It is used to display a help message and exit. |
-s | It is used for the silent mode and print less information. |
-V | It is used to display version information and exit. |
-v | Verbose mode. Print more information. |
Examples Of Replace Command
When you run the replace command without an option, it will fail to execute.
replace
To replace all occurrences of Windows with the word Linux in a file called file.txt, run the commands below:
replace "Windows" "Linux" -- file.txt
When you run the replace command with -? or -I option then it will display a help message as show below:
A from-string can contain these special characters:
\^ Match start of line.
\$ Match end of line.
\b Match space-character, start of line or end of line.
For a end \b the next replace starts locking at the end
space-character. A \b alone in a string matches only a
space-character.
Usage: replace [-?svIV] from to from to ... -- [files]
or
Usage: replace [-?svIV] from to from to ... < fromfile > tofile
Options: -? or -I "Info" -s "silent" -v "verbose"
That’s all.
If you face any error and issue in above steps , please use comment box below to report.
If our tutorials helped you, please consider buying us a coffee. We appreciate your support!
Thank you for your support.