Skip to content

Tag: vi

Why can’t I sudo echo a line in /etc/?

I am on centos and I did sudo echo ‘testline’>>/etc/test/test it said -bash: /etc/test/test: Permission denied However, when I do sudo vi /etc/test/test and insert testline and do :wq it writes out fine, why is this happening? Answer You need to wrap the whole statement (including the redire…

How to add a string to line 13 in my text file

I have a very large text file that is difficult to open in text editors. Lines 12 – 15 are: I would like to add: 3 196 to line 14 and then have a blank line between 3 196 and Atoms like it is currently. I tried: But it did not seem to change anything. Anyone know of how I

vi command to copy certain lines to another file

I have a log file with thousands of lines. I want to copy certain logs ranging between two line numbers to another file so that I can share them within team. For example – I want to copy text from line number 1000 to line 1200 to another file say issueLog.log What is the shortest way to do this? Note:

find and replace a String in vi editor on linux?

i am trying to replace String with new String in Linux vi editor but getting following error. Answer I’d guess the reason you’re getting that error message is because you intend to replace the string on all lines, not just the current one. In order to search all lines, add a % to your command: