Knowledgebase

Unix search commands


Problem:

Searching Files and Directories



Solution:

find / -name [filename] -print (search the whole server for a file)
find . -name [filename] -print (search for a file starting with the current directory)
find / -name [directoryname] - type d -print (search the whole server for a direcory)

grep [text] [filename] (search for text within a file)

sed s/[oldtext]/[newtext]/g [filename] (searches file and replaces all occurances of [oldtext]
with [newtext]