79411562

Date: 2025-02-04 11:48:13
Score: 0.5
Natty:
Report link
egrep -ho '@\w+' "$@" | sort -u

egrep is the same as grep -E, meaning the pattern is interpreted as an extended regular expression. -o makes grep print only the text that matches the pattern, not the whole line. -h makes grep not print the file name. The pattern is any word that begins with @. The "$@" only makes sense if you put this rune into a file, where it will pass any parameters to egrep; otherwise you can just supply file names directly. sort -u sorts the output asciibetically and suppresses repetition.

How to find all the feature files in your suite is less trivial. find -name \*.feature might work for you. You can then find -name \*.feature -print0 | xargs -0r egrep -ho '@\w+' | sort -u to get all the tags in your suite.

One caveat about this: If a word starting with @ is part of a step or table, it will also be printed. You can avoid this by excluding lines that don't have @ as their first non-blank character, like so: egrep '^\s*@' | …

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Starts with a question (0.5): is the
  • Low reputation (1):
Posted by: Antonymous Coward