![]() ![]() The " " command returns true if the string is non-empty, which it always is for this script, so it will always take the first branch of the if statement.īecause $percentUsed is not an integer (it has a trailing '%') could use $% used" The script is executing properly, however, it is creating a zero byteįile by the name 75. In the example below, the find command calculates the md5sum of all the files with the name M圜Program.c (ignoring case).You should use the -gt operator for numeric comparisons what you are doing is saving the (empty) output of the command " " into a file named "75". ![]() Executing Commands on the Files Found by the Find Command. # find -mindepth 3 -maxdepth 5 -name passwd (i.e root - level 1, and two sub-directories - level 2 and 3 ) # find / -maxdepth 3 -name passwdįind the password file between sub-directory level 2 and 4. ![]() ![]() (i.e root - level 1, and one sub-directory - level 2) # find -maxdepth 2 -name passwdįind the passwd file under root and two levels down. usr/share/doc/nss_ldap-253/pam.d/passwdįind the passwd file under root and one level down. Limit Search To Specific Directory Level Using mindepth and maxdepthįind the passwd file under all sub-directories starting from root directory. This example finds all files with name - M圜Program.c (ignoring the case) in the current directory and all its sub-directories. This is a basic usage of the find command. This example finds all files with name - M圜Program.c in the current directory and all its sub-directories. MybashProgram.sh mycprogram.c M圜Program.c Program.c 1. # vim create_sample_files.shĬreate_sample_files.sh mycprogram.c Program.c In this article, let us review 15 practical examples of Linux find command that will be very useful to both newbies and experts.įirst, create the following sample empty files under your home directory to try some of the find command examples mentioned below. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |