Linux cheat sheet
- show disk usage: du
- show disk capacity: df
- search word from file inside directory:
find /start/dir -exec grep -q my_search_word {} \; -print
- search files with specific name inside directory (HP-Unix, maxdepth=1):
find . \( ! -name . -prune \) \( -name “*TEST1*.ps” -o -name “*TEST2*.ps” \) -mtime +30 -type f
find /parent/child \( ! -name child -prune \) \( -name “*TEST1*.ps” -o -name “*TEST2*.ps” \) -mtime +30 -type f
just use grep:
$ grep -r -i [my_search_word] /start/dir/*
-r will search recursively
-i will ignores case-sensitives
you can use awk to print file_name only.
detail see man grep
find will index all files under /start/dir and after that throws as grep input before print to standard output.
cheers…
-bho
thanks for the info mr.bho, it works.
I am suck in awk and sed, will learn about it