Unix Search Commands

CommandSyntaxDescriptionExample
grepgrep [options] pattern file(s)Search for a pattern in a file or filesgrep "error" file1 – Search for the string “error” in file1
findfind [path] [expression]Search for files and directories based on various criteriafind / -name "error.log" – Search for a file named “error.log” starting from the root directory /
locatelocate [pattern]Search for files based on their names using a database of all file names on the systemlocate error.log – Search for a file named “error.log”
whichwhich [command]Show the full path of a commandwhich ls – Show the full path of the ls command
whereiswhereis [command]Show the location of a command’s executable file, source code, and manual pagewhereis ls – Show the location of the ls command’s executable file, source code, and manual page
command | grep
pattern
command | grep
pattern
Search pattern in the output of a commandmore abc.txt | grep exception

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top