📅 2016-Sep-19 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ cheatsheet, find ⬩ 📚 Archive
The find command in Linux is immensely useful. Here are some invocations of this command I find useful:
$ find /usr/include
$ find ../foobar/lib
$ find .
Unlike commands like ls
, note that the find
command is recursive by default. It will list everything under the specified directory.
$ find /usr/include -type f
$ find /usr/foobar -type l
$ find /usr/foobar -type d
$ find /bin -executable
$ find /usr/foobar -type f -or -type l
$ find /usr/foobar -name "exactly_match_this"
$ find /usr/foobar -name "*.this_extension"
$ find /usr/foobar -name "*some_substring*"
$ find /usr/foobar -iname "*someblah*"
$ find /usr/foobar -size 10k
$ find /usr/foobar -size +10k
$ find /usr/foobar -size +10M
$ find /usr/foobar -size +10G
$ find /usr/foobar -size 0
$ find /usr/foobar -newer stdio.cpp
ls -l
on specific files and directories:$ find /usr/foobar -size +20k -ls
$ find /usr/foobar -size +20k -delete
find
to the immensely useful xargs
command. For example, to ls
on the results of find
:$ find /usr/foobar -size +20k | xargs ls -l
Reference:
man find
The Linux Command Line: A Complete Introduction by William Shotts
Tried with: Ubuntu 16.04