fbpx

How to Find Files in Ubuntu Terminal

Here is a list of commands I use to find files in Ubuntu.

To find all files with .zip extension You can use this

find . -name "*.zip"

If you want to find all files with a pattern use this

find . -name "*pattern*"

If you want to exclude a directory, for example dir1 from the search use this command

find . -path ./dir1 -prune -false -o -name '*.txt'

If you want to exclude many directories from the search, use this command

find . -type d \( -path dir1 -o -path dir2 -o -path dir3 \) -prune -false -o -name '*.txt'

If you want to only search for files then you should use this command.

find . -type f -name "*.zip"

If you want to ignore letter case use iname instead of name

find . -iname "*pattern*"

How to find the latest files by modified date

find . -type f -exec ls -lt \{\} \+ | head

Leave a Reply

Your email address will not be published. Required fields are marked *