This guide will work for most Unix-like operating systems. A lot of people probably know about this or similar approaches, but many new users don't.
If you have a Unix-like OS with a Desktop Environment, you probably search for files on your system or in storage by using a file manager's search tool (inputting something into the find field in dolphin/nemo/thunar/caja etc). If you have many files, such a search could take a lot of time to complete and find what you want, dozens of minutes in some cases. For example, I have caja on my GhostBSD and it can take forever to look for something on a multi-terabyte drive.
There is a much more efficient way to look for files by creating a list of contents on your file system with
You can create a list which would include files' and directories' names, modification dates and sizes with the following command:
To list only files:
Then if you want to find files containing "BSD" in their names, simply run
It should be noted that
Please note that the basic
You can also exclude paths when using
If you have a Unix-like OS with a Desktop Environment, you probably search for files on your system or in storage by using a file manager's search tool (inputting something into the find field in dolphin/nemo/thunar/caja etc). If you have many files, such a search could take a lot of time to complete and find what you want, dozens of minutes in some cases. For example, I have caja on my GhostBSD and it can take forever to look for something on a multi-terabyte drive.
There is a much more efficient way to look for files by creating a list of contents on your file system with
find and then looking for your file in it with grep, grep usually takes mere seconds to complete even on file lists weighting hundreds megabytes (in my personal experience). The only drawback is that the initial list creating using find command takes time, but you need to do this only once or once in a while to keep the file list updated. The initial file creation process shouldn't take longer than a regular search using the file manager and you won't need to bother your drives with find requests anymore.You can create a list which would include files' and directories' names, modification dates and sizes with the following command:
find path-to-directory-where-you'd-like-to-look-for-files -printf "%t %s %p\n" > contentsTo list only files:
find path-to-directory-where-you'd-like-to-look-for-files -type f -printf "%t %s %p\n" > filesThen if you want to find files containing "BSD" in their names, simply run
grep BSD filesIt should be noted that
grep is a very versatile command and there are many ways to tweak the search querries to get more exact search results.Please note that the basic
grep command is case-sensitive! find command can also be tweaked in various ways to add the file/directory information you'd expect to look for into contents lists.You can also exclude paths when using
find, for example: find / -path "/home" -prune -o -path "/media" -prune -o -type f -printf "%t %s %p\n" > system_files