I have a directory with number of files. My requirement is, I have to search for the file-names(not file data) based on particular keyword and print that filename.
For example
ABC is the directory. Below it are files
AEXP/INC/ARP.txt
AEXP/OPC/ARP.txt
AEXP/INC/PQW.txt
I want the files contains with the keyword INC.
Expected output:
AEXP/INC/ARP.txt
AEXP/INC/PQW.txt
I tried this logic, But it is not working properly
#!/bin/sh
for FILE in ABC/* do
if [[ $file =~ /INC/i ]] then
echo success;
else
echo fail;
fi
done
Please help me to get the right answer. bash script, Perl, regex, anything is fine.
Aucun commentaire:
Enregistrer un commentaire