Specifying -maxdepth 2 searches the directory and one subdirectory deep: find. If any subdirectories are found, they are listed, but not searched. To restrict how many levels of subdirectory to search, you can use the -maxdepth option with a number.įor instance, specifying -maxdepth 1 searches only in the directory where the search begins. imagesīut this time, the output reflects the starting location of the search and looks like this:īy default, the search looks in every subdirectory of your starting location. If our working directory is /home/hope/Documents, we can use the following command, which finds the same files: find. Notice that the full path is also shown in the results. home/hope/Documents/images/memes/picard.jpg home/hope/Documents/images/memes/goodguygary.JPG home/hope/Documents/images/memes/winteriscoming.jpg To only list files and subdirectories that are contained in the directory /home/hope/Documents/images, specify the first argument of the command as: find /home/hope/Documents/images It's good practice to use this form of the command. If you try to use it on another Unix-like operating system, such as FreeBSD, specifying a directory is required. The example above is the "proper" way to use find. Running find with no options is the same as specifying that the search should begin in the working directory, like this: find. Notice that the output starts with a single dot, which represents the working directory. In this example, we see a total of ten files and four subdirectories in and beneath our Documents folder. Now let's run find without any options: find First, let's check our working directory using the pwd command: pwd Every file in each of those subdirectories.Every subdirectory in /home/hope/Documents.For instance, if your working directory is /home/hope/Documents, running find outputs the following: Running find without any options produces a list of every file and directory in and beneath the working directory. Finding files based on modification, access, or status change.Finding only files, or only directories.which outputs something like this: 1 username staff 397 1 username staff 16899 1 username staff 9202 Apr 20 12:44 1 username staff 4268 1 username staff 40272 1 username staff 274 1 username staff 3989 Apr 16 22:12 1 username staff 3177 1 username staff 2684 1 username staff 1997 1 username staff 2546 Nov 15 14:47 1 username staff 27695 Nov 23 06:03 1 username staff 7777 1 username staff 413 1 username staff 334 1 username staff 9913 1 username staff 18545 Nov 15 19:44 1 username staff 3702 1 username staff 3266 xmlrpc. Then if you want more information, try this: mac:wordpress username$ ls -la *> file-list-full.txt files-all.txt List contents of directory mac:wordpress username$ ls -m1 *> file-list.txt files-recursive.txt Get everything find. List all files, first level folders, and their contents ls * -r List all first-level subdirectories and files file */* Save file list to text file */* *>. now having collected some useful commands, I want to post ‘em for future reference. As I’m not an expert in Terminal, it took awhile to figure out the magic recipe. From time to time I have occasion to generate a list all WordPress files or similar.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |