Menu

Monday, July 4, 2011

Find Command

  • Find command Syntax.
  • # find [path] [expression]
  • Frequently Asked Questions in Find Command
  • 1. How to find a directory?
    • Syntax
    • # find / -name folder-name –type d
    • Example:
    • # find / -name subversion –type d
    • The above command will search subversion folder in the root directory.
    • / - means root directory
    • d - means search only directories
  • 2. How to find a file?
    • Syntax
    • # find . -name file-name -type f
    • Example:
    • # find . -name news.xml -type f
    • The above command will search news.xml file in the current directory.
    • . - means current directory
    • f - means search only files
  • 3. How to find symbolic links?
    • Syntax
    • # find . -name file-name -type l
    • Example:
    • # find . -name feed -type l
    • The above command will search feed symbolic link in the current directory.
    • . - means current directory
    • f - means file
  • 4. Other interesting options in find with example
    • Example:
    • find . -name "*.txt" -print
    • The above command will finds all the files with txt extension.