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
+12.6k Golang : zlib compress file example
+5.2k Python : Convert(cast) string to bytes example
+14.9k Golang : package is not in GOROOT during compilation
+11.9k Golang : Convert a rune to unicode style string \u
+8.8k Golang : Inject/embed Javascript before sending out to browser example
+14.4k Golang : Send email with attachment(RFC2822) using Gmail API example
+3.3k Golang : Fix go-cron set time not working issue
+20.4k Nginx + FastCGI + Go Setup.
+5.8k AWS S3 : Prevent Hotlinking policy
+6.1k PHP : How to handle URI or URL with non-ASCII characters such as Chinese/Japanese/Korean(CJK) ?
+10.7k Golang : Get UDP client IP address and differentiate clients by port number
+8.1k Swift : Convert (cast) Character to Integer?