
$ find /home -type f -iname "example.txt"įind all.

png image files in the /home directory and its subdirectories:Ĭonsider using the type -f option to only search for files (ignore directories), and the -iname option to make your search case insensitive: Search your present working directory and its subdirectories for a particular file:įind all. Through the following examples and explanations, you’ll learn how to use it. So all you really need to know is how to use the command effectively. When it comes to finding a particular file or set of files, the find command is your best friend on Linux. Most of this section will revolve around the find command. $ – requires given linux commands to be executed as a regular non-privileged user # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command Privileged access to your Linux system as root or via the sudo command. Requirements, Conventions or Software Version Used How to find file in Linux Software Requirements and Linux Command Line Conventions Category For all these files execute the copyfiles.sh script.that have been modified within the past 30 days.Find all files in the directory /mnt/nas.The example below would do the following: Please modify the following command to your needs. Now you'll need to make that file executable: chmod 755 copyfiles.sh The filename with the filepath which is delivered by 'find'įor the function to work you'll need to create a new file called copyfiles.sh and put the following code into it: #!/bin/bashĭEST_DIR=`echo "$SRC_DIR" | sed "s#$2#$3#"`.This cannot be done with a simple unix command thus we needed to develop a small script for this. We needed to copy all files that were modified within the past 28 days from all subdirectories to another place whilst maintaining the whole directory structure.
