Language: EN

comandos-linux-busqueda

Linux Commands - File and Content Search

Here is a compilation of the most useful Linux commands for File and Content Search


# search for file and directory by name in the entire system
find * -name name


# search for file and directory by name, within directory
find directory -name name


# search for files and directories belonging to user, within directory
find directory -user user


# search for files and directories by type, within directory
(d directory, f regular file, l symbolic link)
find directory -type f type


# search for files and execute command
find directory -name name -exec command {} \;


# search for files with .ps extension
locate \*.ps


# display the full path of an executable
which executable 


# display the location of a binary, help, or source file
whereis executable 

Search in file content


# search for string in file(s)
grep string file


# search for string in file(s) without case matching
grep -i string file
 

# search for words that start with string in file(s)
grep ^string file 


# search for string as a whole word in file(s)
grep -w string file 


# select the lines from file that contain numbers
grep [0-9] file 


# recursive search for string in directory
grep string -R directory 

To see the complete compilation of Linux commands, visit this link: List of Linux commands