sed + remove "#" and empty lines with one sed command -
How to remove lines (# hair bla) and empty lines (without line line) with a comment With command?
THX Lydia
If you are concerned about starting two
In line, you probably should not be, it is not not disabled.
However, if you want to do a single process, you can use multiple -e
arguments, something like this:
sed -e's /#.*$// '-e' / ^ $ / d 'input file
why In response to your comment, you want to use a single process, sed -i
for in-place editing, you can also do the following transcript:
pax> 'Line # echo' with a comment & gt; Qq pax & gt; Echo & gt; & Gt; Cuk pax & gt; Repeat '# Line' with only one comment & gt; & Gt; Qq pax & gt; Cat qq line # with a comment #include only a comment pax & gt; Sed -i -e's /#.*$// '-e' / ^ $ / d 'qq pax & gt; Cat qq line pax & gt; _
Note that how the file has been changed to two, along with two -e
options. You can see that the two commands are executed on each line, with comments, the comment has been removed in the first line, then all are deleted because it is empty.
In addition, the original blank line is also deleted.
Comments
Post a Comment