#!/bin/bash # resources # https://www.sentinelone.com/blog/search-your-files-with-grep-and-regex/ # https://jex.im/regulex/#!flags=&re=%5E(a%7Cb)*%3F%24 # https://regex101.com/r/8NLngW/1 # https://www.cyberciti.biz/faq/grep-regular-expressions/ # Also you can always ask ChatGPT for specifics # regex101 flavor: # /\[.*(?!^$)([^\s]).*\]/gm clang-format ./program.c | grep -E '^[^\/\/]*\[[^]]+\]' echo '------------------------------' clang-format ./program.c | grep -E '^[^/]*\[[^]]+\][^/]*$' echo '------------------------------' clang-format ./program.c | grep -E '^[^/]*[^[:alnum:]_]\[[^]]+\][^[:alnum:]_]'