Search for files using SSH

To search the current directory and all subdirectories for a folder or file, use the following command:

find . -name filename

– where filename is the file or folder for which you are looking…
To search one directory and all its subdirectories use the following command:

find foldername -name filename

– where filename is the file or folder for which you are looking and foldername is the folder in which you want to search.

To search for files containing a string

grep -ir search_string *

– i denotes case insensitive and r is for recursive

To count number of files in a directory

ls -ral | grep '-' -c

Leave a Reply

Your email address will not be published.