

In this article, we will start by explaining the basic Linux find commands with examples. Adding the -exec option enables sysadmins to run external commands and perform actions like copying, moving, deleting, or changing permissions of the files matching the specified criteria such as size, name, etc. It can find directories and files by their name, their type, or extension, size, permissions, etc.īesides locating files and directories, combining the find command with others enables you to take action on the results. tsconfig.json 5.The Linux find command is a powerful tool that enables system administrators to locate and manage files and directories based on a wide range of search criteria. Let’s look at how we can use the exec option to execute the stat commands for each file found by the find command: $ find. But, using the exec option might be slower than xargs, and it’s more difficult to read. The exec option of the find command can be used similarly to the xargs command used above. The man page of the find command contains the full list of possible values for k. %Tk – file’s last modification time in a format specified by k.The full list of escapes and directives can be found in the man pages, but let’s take a look at some of them: The hyphen (-) between the % sign and the width specifies that the interpreted value should be left-padded. The field width of a directive is specified after the % sign of a directive. If the width of the interpreted value for that directive is less than the specified width, then it is padded with whitespace.

The unit for the width of a directive is the number of characters. In the above example, we’re specifying something called a field width inside the filename printf directive.
