Regex remove comments but not shebang

I got a regex that removes the comments in bash using this regex code

'/^\#/d'

but it also removes the #! which should be not because it's not a comment tag but a shebang

so how can it be done to ignore #! in regex?

Answers


This line will remove every comment starting with # but is not followed by an !.

'/^#[^!]/d'

This makes the ! optional

'/^#[^!]*/d'

Need Your Help

Running same Asynctask multiple times sequentially

android android-asynctask

I am trying to execute same Asynctask sequentially. For example, Let there be an Asynctask A. Now assume A checks if some server is busy or not. If it's busy, it checks again.... And so on. Let's s...

How to handle files in an OOP way?

php oop symfony2 symfony-2.1

I need to copy, move, and delete files.