I am using Linux (centos flavor) and created a file with the following text:
" hello world "
Question:
Now, I opened the file in vi editor mode and am able to remove all non blank characters(backspace or delete keys do nothing). But newline characters persist and I get error saying “no previous regular expression”.
What should I do to remove all the new lines so that my file is just empty?? I have tried backspace key many times but no effect and I do not want to use cat > filename
to just overwrite the file to make it empty!
Advertisement
Answer
You can use dd
to delete any lines in vi
editor.
Example: You have a file having 6 lines and you want to delete all 6 lines:
- Open the file using ‘vi` editor
- Go to first line
- use
6dd