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
+29.8k Golang : Get time.Duration in year, month, week or day
+8.8k Golang : Accept any number of function arguments with three dots(...)
+12.2k Golang : Print UTF-8 fonts on image example
+34.5k Golang : How to stream file to client(browser) or write to http.ResponseWriter?
+7.6k Golang : get the current working directory of a running program
+11.8k Golang : Setup API server or gateway with Caddy and http.ListenAndServe() function example
+16.3k Golang :Trim white spaces from a string
+19.1k Golang : Delete item from slice based on index/key position
+8.1k Golang : Metaprogramming example of wrapping a function
+7.1k CloudFlare : Another way to get visitor's real IP address
+9k Golang : Simple histogram example
+13k Golang : How to get a user home directory path?