Home > Blockchain >  simplify find command with 0 or 1 time repeat pattern
simplify find command with 0 or 1 time repeat pattern

Time:10-06

How can I simplify below find command with pattern:

find . -type d -name symbols -o -name symbol

The pattern is 'symbol' 0 or 1 's'.

CodePudding user response:

You can use a -regex, but it must match the whole path, so you need to prepend .*/ to match the path.

find . -type d -regex '.*/symbols?'
  • Related