Thefindcommand can also search through the directory, entering subdirectories to find the specified file or folder. Suppose we have many files namedtestscattered in folders in our current directory. To see where they are located, we can type the following. ...
首先,在你的home目录下面创建下面的空文件,来测试下面的find命令示例。 # vim create_sample_files.shtouch MybashProgram.sh touch mycprogram.c touch MyCProgram.c touch Program.cmkdir backupcd backup touch MybashProgram.sh touch mycprogram.c touch MyCProgram.c touch Program.c # chmod +x create_sam...
The number of sub-directories can be quite large.How tofind the number of files in each sub-directories here? You can use this piece ofscriptto find the number of files in sub directories: foriin`ls -1`;doecho$i; find$i-type f | wc-l;done ...
which is time and resource consuming. However the depth of directory travesal can be specified. For example we don't want to go more than 2 or 3 levels down in the sub directories. This is done using the maxdepth option.
31. Find Accessed Files in Last 1 Hour To find all the files which are accessed in the last1 hour. # find / -amin -60 Part V – Find Files and Directories Based on Size Here are some examples of find commands for locating files and directories based on size. ...
Find all files (-f) in the current directory (.) and2subdirectories below (-maxdepth 3includes the current working directory and 2 levels down) whose size (-size) is greater than2 MB. # find . -maxdepth 3 -type f -size +2M ...
/home/sara/Documents. Represents the directory where the search begins. Thefindcommand recursively searches through this directory and its subdirectories. -type f. Restricts the search to regular files only. -exec. Allows you to execute a command on each file thatfindmatches. In this case, it ...
MybashProgram.sh mycprogram.c MyCProgram.c Program.c 1. Find Files Using Name 根据文件名查找 This is a basic usage of the find command. This example finds all files with name — MyCProgram.c in the current directory and all it’s sub-directories. ...
When find is examining a directory, after it has statted 2 fewer subdirectories than the directory’s link count, it knows that the rest of the entries in the directory are non-directories ('leaf' files in the directory tree). If only the files' names need to be examined, there is ...
cd backuptouchMybashProgram.shtouchmycprogram.ctouchMyCProgram.ctouchProgram.cchmod+x create_sample_files.sh# ./create_sample_files.sh#ls-R backup backup/: MybashProgram.shmycprogram.c MyCProgram.c Program.c 1. 用文件名查找文件 这是find命令的一个基本用法。下面的例子展示了用MyCProgram.c作为...