Suppose that I have a directory with thousands of files; how could I open all files whose name contains both the strings "red" and "green"?
Bash Scripting – How to Open or List Files Matching Two Patterns
bashwildcards
bashwildcards
Suppose that I have a directory with thousands of files; how could I open all files whose name contains both the strings "red" and "green"?
Best Answer
(On the assumption that you're looking for file names that contain both the string "red" and the string "green")
To pointlessly use bash to test filenames against 'red' and 'green' using the
=~
regular expression match operator:To use standard shell syntax using
case
and globs to find the same files:Even simpler, with your shell's globbing:
Sample run: