sed + remove “#” and empty lines with one sed command

后端 未结 7 2086
旧巷少年郎
旧巷少年郎 2020-12-08 02:57

how to remove comment lines (as # bal bla ) and empty lines (lines without charecters) from file with one sed command?

THX lidia

7条回答
  •  庸人自扰
    2020-12-08 03:30

    First example(paxdiablo) is very good except its not change file, just output result. If you want to change it inline:

    sudo sed -i 's/#.*$//;/^$/d' inputFile

提交回复
热议问题