Command to find a file in Unix with Example

The find command is used to locate files on a Unix or Linux system.  find will search any set of directories you specify for files that match the supplied search criteria.  You can search for files by name,  type,  date, size and other criteria.
  •  Find Files Using Name in Current Directory
Find all the files with name tecgeeks.tar in a current working directory.

# find . -name tecgeeks.tar

  • Find Files Under Home Directory
Find all the files under /home directory with name tecgeeks.txt.

# find /home -name tecgeeks.txt


  • Find Directories Using Name
Find all directories with name  TecGeeks in / directory.

# find / -type d -name TecGeeks 


  • Find all Empty Files
To file all empty files in the OS .

# find  -type f -empty


  • Find all Empty Directories
To file all empty directories in the OS

# find  -type d -empty


  • File all Hidden Files
To find all hidden files, use below command.

# find  -type f -name ".*"


  • Find Changed Files in Last 1 Hour

To find all the files which are changed in last 1 hour.

# find / -cmin -60

  • Find Modified Files in Last 1 Hour

To find all the files which are modified in last 1 hour.

# find / -mmin -60

  • Find  Files based on their size 

To find all 50MB files,

# find / -size 50M
Command to find a file in Unix with Example Command to find a file in Unix with Example Reviewed by TecGeeks News on April 30, 2016 Rating: 5

No comments:

Get Your Business Online Now


Powered by Blogger.