How to Find a Directory in Unix
Edited by Archana Nagarajan, Qimu, Anna, Akhilesh oz and 2 others
You can find a directory in UNIX using the 'find' command.
This article has been tagged as a stub. That means it's off to a good start, but still has plenty of room to grow before it reaches its full potential. Can you help it flourish? If you think the article offers complete and accurate instructions, feel free to remove this tag! |
EditSteps
-
1Know the syntax for using 'find' command. This can search for a file or directory:
- find <path> -name <file_or_directory_name>
-
2Use the below command to search for a directory 'dir1' in your current working directory
- find . -name dir1
-
3Use the below command to search for a directory 'dir1' in the folder 'wikidocs'.
- find wikidocs -name dir1
-
4Use below command to search for a directory 'dir1' within the filesystem '/'
- find / -name dir1
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.