Most of you encounter a situation where you need to replace the text in Linux file. Recently I need to do this in Ubuntu server for changing repo "US" to "local" repo. Therefore here is the process how to change it.
You can use vi and vim text editor comes with every Linux OS, if your Linux don't have full function text editor then use this link to install it.
In my case I use it for replace international repo to local repo, you can use for any text replacement.
So I use word "US" to replace with "NP", Which is local for me.
Now use the following command to edit repo source
#sudo vi /etc/apt/sources.list
You can see repo source list file is opened, then just use the following syntax to replace the text: In my case I use "us" and "np" word, please replace these with your desire word.
:%s/us/np/g
or if you need to conformation then you us this command, mean if you don't need to replace whole text.
:%s/us/np/gc
following command can be used for current line only
:s/us/np/g
You can use vi and vim text editor comes with every Linux OS, if your Linux don't have full function text editor then use this link to install it.
In my case I use it for replace international repo to local repo, you can use for any text replacement.
So I use word "US" to replace with "NP", Which is local for me.
Now use the following command to edit repo source
#sudo vi /etc/apt/sources.list
You can see repo source list file is opened, then just use the following syntax to replace the text: In my case I use "us" and "np" word, please replace these with your desire word.
:%s/us/np/g
or if you need to conformation then you us this command, mean if you don't need to replace whole text.
:%s/us/np/gc
following command can be used for current line only
:s/us/np/g
Comments
Post a Comment