Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Find Cheatsheet

📅 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
$ find /usr/foobar -size +20k -ls
$ find /usr/foobar -size +20k -delete
$ find /usr/foobar -size +20k | xargs ls -l

Reference:

Tried with: Ubuntu 16.04


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧