Monday, December 26, 2005

unix tip: find - limit the depth

by default find will search all subdirectories under the parent directory. but you can limit the depth by using maxdepth option.

- to limit it only to the current directory and not search through any subdirectories, use the -maxdepth 1 option.
$ find . -maxdepth 1 -name test

- to search one level below of the directory use the -maxdepth 2 option.
$ find . -maxdepth 2 -name test

- if not using -maxdepth option.
$ find . -name test

Wednesday, December 21, 2005

unix tip: one-liner find files with different regex

instead of we type find a few times, we can use -o option.

$ find . -name "*ksh" -o -name "*txt"