cancel
Showing results for 
Search instead for 
Did you mean: 
ricardodacosta
Moderator
Moderator
  • 5,730 Views

I show you mine, you show me yours: What is your favorite regex to use?

I troubleshoot botched configs very often and I hate seeing the annotations (comment lines), they distract from the main lines in a configuration file, and makes it harder to find the erronous line.

I use this:

 

grep '^[^#]' /path/to/file

or

 

grep -vE ‘^\s*(#|$)’ /path/to/file

----------------------------------------------------------------------------------------------------------------------
If you're satisfied with the solutions provided please mark the solution as ACCEPTED.

Don't forget to thank those who helped you out with kudos!Both will strip your config file of lines beginning with a # and blank lines, but the latter also strips those lines which have spaces then the #.

 

 

 

 

 

 

 

 

 

Tags (3)
11 Replies
kaiser
Flight Engineer
Flight Engineer
  • 528 Views

Looking at your reply , I read back the whole post and figured out that I did not read the post properly before.

My reply was there just after reading some of the grep command lol.

My mistake  

0 Kudos
Chetan_Tiwary_
Community Manager
Community Manager
  • 523 Views

@kaiser np at all !!  :xD 

0 Kudos
Join the discussion
You must log in to join this conversation.