I am searching for a way to extract "screaming snake case" strings from multiple files.
Screaming snake case is upper case words separated by underscore.
A regular expression would be ([A-Z]*_?[A-Z]*)*
.
Now I am searching for a way to find such matching strings in multiple files. I expect grep or find could help?
What I have:
For example:
Some text WITH some SNAKE_CASE words.
The output should be a list like:
WITH
SNAKE_CASE
The use case for this is, that the snake case words are used as i18n keys for maintaining a properties file but there is no IDE support to keep all of them in sync.
What I am now using is:
find . -name "*.js" -exec grep -oP '\b[A-Z]+(_[A-Z]+)*\b' {} + | cut -d':' -f2 | sort | uniq
Thanks for support
Think you mean this,
grep -oP '\b[A-Z]+(_[A-Z]+)*\b' file
Just pass the above regex to find command.
find FOLDER -type f -exec grep -oP '\b[A-Z]+(_[A-Z]+)*\b' {} +
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With