Skip to main content
added 115 characters in body
Source Link
eckes
  • 67.7k
  • 31
  • 177
  • 209
grep -i "something ~\* '[[:alnum:]]*'" /var/log/syslog 

works for me.

  • escape the first * to match a literal * instead of making it the zero-or-more-matches character:
    ~* would match zero or more occurrences of ~ while
    ~\* matches the expression ~* after something
  • use double brackets around :alnum: (see example here)
  • use a * after [[:alnum::]] to match not only one character between your single quotes but several of them
  • the single quotes don't have to be escaped at all because they are contained in an expression that is limited by double quotes.
grep -i "something ~\* '[[:alnum:]]*'" /var/log/syslog 

works for me.

  • escape the first * to match a literal * instead of making it the zero-or-more-matches character
  • use double brackets around :alnum: (see example here)
  • use a * after [[:alnum::]] to match not only one character between your single quotes but several of them
grep -i "something ~\* '[[:alnum:]]*'" /var/log/syslog 

works for me.

  • escape the first * to match a literal * instead of making it the zero-or-more-matches character:
    ~* would match zero or more occurrences of ~ while
    ~\* matches the expression ~* after something
  • use double brackets around :alnum: (see example here)
  • use a * after [[:alnum::]] to match not only one character between your single quotes but several of them
  • the single quotes don't have to be escaped at all because they are contained in an expression that is limited by double quotes.
Source Link
eckes
  • 67.7k
  • 31
  • 177
  • 209

grep -i "something ~\* '[[:alnum:]]*'" /var/log/syslog 

works for me.

  • escape the first * to match a literal * instead of making it the zero-or-more-matches character
  • use double brackets around :alnum: (see example here)
  • use a * after [[:alnum::]] to match not only one character between your single quotes but several of them