Edit Article

Edited by Archana Nagarajan, Qimu, Anna, Akhilesh oz and 2 others

You can find a directory in UNIX using the 'find' command.

EditSteps

  1. 1
    Know the syntax for using 'find' command. This can search for a file or directory:
    • find <path> -name <file_or_directory_name>
  2. 2
    Use the below command to search for a directory 'dir1' in your current working directory
    • find . -name dir1
  3. 3
    Use the below command to search for a directory 'dir1' in the folder 'wikidocs'.
    • find wikidocs -name dir1
  4. Find .jpg
    4
    Use below command to search for a directory 'dir1' within the filesystem '/'
    • find / -name dir1
Add your own method
Save

EditTips

  • To distinguish between searches for files and folders, 'find' command offers the -type predicate.
  • find <path> -name <file_or_directory_name> -type d [ where d denotes directory. To search for files, replace 'd' with 'f' ]
  • But unlike Windows, UNIX treats all devices, be they files, directories, sockets, pipes etc as FILES and each device must have a unique name. So there will never be a scenario where a file or directory share the same name, thus making the use of the -type predicate unnecessary.

Article Info

Categories: Stub | Operating Systems

Recent edits by: Wingrider, Akhilesh oz, Anna

Thanks to all authors for creating a page that has been read 51 times.

Was this article accurate?

YesNo