0

How to delete all lines starting with # ?

Asked 3 years ago (May 10, 2021) in the field of Programming by Edgar

I need to check a file and I wish to know how to delete all the unnecessary content? Thank you


Answers


0
Answered 3 years ago (May 11, 2021) by Eldernode Staff

To do this, go to the desired directory, for example:

cd /root

Then create a file with the help of an editor and copy the relevant file codes into it and save the file. For example with this name:

nano test123.file

Finally, by executing the following command, all lines that started with # are deleted completely:

sed -i '/^#/d' test123.file

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day