0

how can I do a search like these into bash shell?

1) Search all files that start having name starting with mysql- (and then something else) into a specific folder (and all its subfolder)

2) Search if into some files (configuration\textual) into a specific folder there is the content starting with mysql- (and then something else)

1

2 Answers 2

1

Your question is a bit confused, however as I understand it as:

1) You want to find all files starting with mysql- in specific folder(directory) and it's subtree:

find <your directory here> -name "mysql-*"

2) Find all files in specified directory which contain mysql-:

cd <your directory here> && grep -R mysql- *

if you really want just filenames, add cut filter:

cd <your directory here> && grep -R mysql- * | cut -d ":" -f1 | sort | uniq
1
  1. use find command :

    find MYDIR -iname mysql-* -type f
    
  2. use grep command :

    grep -rn 'mysql-' MYDIR
    

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .