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
+37.6k Golang : How to read CSV file
+9.5k Golang : Replace a parameter's value inside a configuration file example
+18.4k Golang : How to count the number of repeated characters in a string?
+11.9k Golang : Count number of runes in string
+5.4k WARNING: UNPROTECTED PRIVATE KEY FILE! error message
+50k Golang : Check if item is in slice/array
+10.6k Golang : Perform sanity checks on filename example
+18.9k Golang : Secure(TLS) connection between server and client
+24.9k Golang : Convert file content into array of bytes
+3.1k Detect if Google Analytics and Developer Media are loaded properly or not
+10.5k Golang : Handle API query by curl with Gorilla Queries example
+7.8k Golang : How to use Gorilla webtoolkit context package properly