How to find files and folders on your account via SSH
Searching and finding files and directories on your hosting account through SSH can be done with the find command. Depending on the options that you use with the command you can search for files according to different criteria: name, file extension, size, time of last modification, permissions, etc. So you need to know at least something about the file that you want to find in order to narrow the search. The easiest way is if you know the name of the file. In this case use the command followed by the option -name and the name of the file. For example:
find -name example.txt
will find all files called example.txt that are in the current working directory and all its subdirectories. If you want to ignore case differences you can use the -iname option. For example, find -iname example.txt will search for files like example.txt, EXAMPLE.txt, Example.txt, etc. You can also use wildcards to search for files with the same name but different file extensions, or for files from the same type. Put quotation marks around the name and the wildcard, or around the wildcard and the extension type, depending on the search. For example:
find -iname "example.*"
will find all files within the current working directory and its subdirectories that are named example (e.g. example.txt, example.php, example.html, etc.). The search will be case insensitive (because of the -iname option). If you don't use the dot after the name but just the wildcard (e.g. find -iname "example*"), this will list all files and directories that have example in their name (e.g. example2.txt, example_file.php, example dir, etc.). While the command:
find -iname "*.txt"
will find all txt files in the current working directory and its subdirectories. You can also search for a file based on other things than its name or extension type. For example, you can search for files based on their size with the -size option. For instance, find -size +50M will find all files in the current working directory and its subdirectories that are over 50 megabytes in size (for gigabytes use G, for kilobytes k, for bytes c). You can also set an upper and lower limit; for example, find -size +50M -size -200M will list all files in the current directory and its subdirectories that are larger than 50 megabytes but smaller than 200.
Another option that might be useful is -perm. It is used to search for files having the specified permissions. For example, find -perm 777 will list all files in the current working directory and its subdirectories that have permissions of 777 (useful if you want to find files that have world-writable permissions).
To limit the search just to files or directories you can use the options -type f and -type d respectively. For example:
find -iname "example*" -type d
will list all folders that are in the current working directory and its subdirectories, and which have example in their name (e.g. example dir, example3, example_folder, etc.). The search will be case insensitive because of -iname. For a case sensitive search, as we already mentioned, use the option -name.