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
+5.5k Golang : Shortening import identifier
+5.2k Golang : The Tao of importing package
+6.2k Golang & Javascript : How to save cropped image to file on server
+22.8k Golang : Gorilla mux routing example
+11k How to test Facebook App on localhost ?
+4.1k Javascript : Empty an array example
+15.2k Golang : How to get Unix file descriptor for console and file
+10.7k PHP : Convert(cast) bigInt to string
+10.8k Golang : Removes punctuation or defined delimiter from the user's input
+6.7k Golang : Get expvar(export variables) to work with multiplexer
+5.9k Fontello : How to load and use fonts?
+15.2k nginx: [emerg] unknown directive "ssl"