mercredi 29 mai 2019

Bash - check if any of the files within a folder contain a pattern then return filename

I'm writing a script that aim to automate the fullfill of some variables and i'm looking for help to achieve this:

I have a nginx sites-enabled folder wich contain some reverses proxied sites. I need to: 1: check if a pattern $var1 is found in any of the files in "/volume1/nginx/sites-enabled/" 2: return the name of the file containing $var1 as $var2

Many thanks for your attention and help!

i have found some lines but none try any files in a folder

if grep -q $var1 "/volume1/nginx/sites-enabled/testfile"; then echo "found" fi

Aucun commentaire:

Enregistrer un commentaire