bash - How to collect the files with specific keyword in their file names within a directory -
i have directory number of files. requirement is, have search file-names(not file data) based on particular keyword , print filename.
for example
abc
directory. below files
aexp/inc/arp.txt aexp/opc/arp.txt aexp/inc/pqw.txt
i want files contains keyword inc
.
expected output:
aexp/inc/arp.txt aexp/inc/pqw.txt
i tried logic, not working properly
#!/bin/sh file in abc/* if [[ $file =~ /inc/i ]] echo success; else echo fail; fi done
please me right answer. bash script, perl, regex, fine.
on linux use "find". on ubuntu shell, looks like:
find . -name "*inc*" -print
Comments
Post a Comment