Using BASH command Find to locate files – Part 1


P1. Use command to list files in the lammps-7Aug19 directory

[u1@node1 lammps-7Aug19]$ find

Pt 2. Count the number of files by piping the list to wc to count the files.

[u1@node1 lammps-7Aug19]$ find | wc -l
14717

P3. Count the the directories listing by piping the list to wc to count the directories

[u1@node1 lammps-7Aug19]$ find -type d | wc -l
672

P4. Count the list of files that matched the wildcard pattern *.mov that are larger than 1M by piping to wc to count

[u1@node1 lammps-7Aug19]$ find -type f -name "*.jpg" -size +1M |wc -l

P5.  Find and match files or directories whose contents or attributes were last modified more recently than those of “mybasefile”

[u1@node1 lammps-7Aug19]$ find -type f -name "*.jpg" -cnewer mybasefile

P6. Find empty files in the lammps-7Aug19 directory

[u1@node1 lammps-7Aug19]$ find -type f -empty

Pt 7. Find files or directories that belongs to username

[u1@node1 Downloads]$ find -type f -user root |wc -l
1572

References:

  1. The Linux Command Line

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.