Home > database >  How to select files based on multiple patterns (logical AND)
How to select files based on multiple patterns (logical AND)

Time:11-05

I am trying to run a code and part of this requires me to select all files that contain the phrase "peanuts".

Ex:
peanut_butter_1.txt
peanut_sauce_2.txt
potato_salad_2.txt
peanuts_1.txt

for this if I signify

/data/peanut_dir/yum/*peanut*

The code will run with only the three files that contain "peanut". If I try to run this to select only files that have "peanut" AND "1" with the same syntax *peanut* *1*, it does not work. If I try to capture using `awk '/peanut/ && /1/', I get an error

FileNotFoundError: [Errno 2] No such file or directory: '/data/peanut_dir/yum/awk'

How can I replicate the syntax for one pattern, using two patterns? (I am new to command line, I apologize if this is basic)

CodePudding user response:

/data/peanut_dir/yum/*peanut*1*
  • Related