Being my first week, had a lot to do. I have been familiarising myself with Unix commands, weird but very useful navigation and controls of the Emacs editor, Git and oddly satisfying Python exercises.

The topic for my presentation last week was find command. As the name suggests find command is used to find files and directories and it let us perform operation on them. With find command, we can search files and directories by name , date, permissions, size, time,and owner.


$ find [where to search]  [expression that say what to find] -[options] [what to find]

Below are different cases find can be used:

$ find .

This finds all directories and files in current directory. We can use path to any directory instead of using current directory which will list all its contents.

$ find /home/majid

To find file or directory, we can use option -type with f or d. Similarly we can use option -name for finding files or directories with name specified in quotes.

$ find . -type f  -name "*.txt"

The above command will list all the text files in the current directory. There is another option of finding with permission for file or directory, -perm. It should be followed pemission in octal. Also we can perform operation on found file or directory with the -exec option followed by command. It can be done as follows.

$ find . -perm 777 -exec chmod 774 {} \;

This will change all files and directories with permission 777 to permission 774. Another use of find command is to find files and directories according to their size and time of accessing, modifying and changes. For time option time specifies a day and min specifies a minute and it should be following m or c  or a for specifying modify or change or access.

  $ find . -type f -mmin +10 -size -10M

This will list all files that are modified more than 10 minutes ago and size less than 10M. size and time can be used twice to specify a range of size or time.

With find we can also find files by owner. It is done by -user option followed by username. The following will list all files and directories for which owner is majid.

$ find / -user majid

Keep waiting for more. Thanks .