Skip to main content
edited title
Link
geckels1
  • 173
  • 2
  • 8

In a bash script, using =~, how do I match the regex "^#^#.*${new_user}"?

Source Link
geckels1
  • 173
  • 2
  • 8

In a bash script, using =~, how do I match the regex "^#.*${new_user}"?

Title basically says it all, but I can't figure it out for the life of me and getting confused by bash regular expression matching. This is the if statement I have in my bash script, but it keeps matching the line ${new_user} instead of # ${new_user}. I basically want to match a "commented out" user.

if [[ $(<"foo.txt") =~ \#.*${new_user} ]]; then