Linux/MacOSX : Search for files by filename and extension with find command
Jotting down these useful commands here for future references, never know when I might need to recall them again on how to search for files by filename or extension.
To search current directory and directories under the current directory for files with .go
extension :
>find ~ -type f | grep "\.go$"
Sample output :
/Users/admin/variables.go
/Users/admin/writebyte.go
/Users/admin/writerune.go
/Users/admin/writestring.go
/Users/admin/x509.go
If need to search for more than 1 type of file extension, use grep -E
command to combine the extensions. For instance, to search current directory and directories under the current directory for files with .go
, .py
and .php
extensions :
>find ~ -type f | grep -E "\.go$|\.py$|\.php$"
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+14.5k Golang : Loop each day of the current month example
+11.1k Golang : Forwarding a local port to a remote server example
+4.2k Python : Create Whois client or function example
+7k Golang : Qt splash screen with delay example
+7.9k Golang : Take screen shot of browser with JQuery example
+6.1k Golang : Array mapping with Interface
+8.1k Golang : Create and shuffle deck of cards example
+10.4k Golang : Concurrency and goroutine example
+36.5k Golang : Comparing date or timestamp
+15.4k Golang : read gzipped http response
+12.8k Golang : Chunk split or divide a string into smaller chunk example
+5.6k Golang : Spell checking with ispell example