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
+17.4k Golang : Defer function inside init()
+26.1k Golang : Convert(cast) string to uint8 type and back to string
+8.1k Golang : Count leading or ending zeros(any item of interest) example
+5.8k nginx : force all pages to be SSL
+7.7k Golang : Gomobile init produce "iphoneos" cannot be located error
+13.8k Golang : Reverse IP address for reverse DNS lookup example
+16.3k Golang : Delete files by extension
+10.2k Swift : Convert (cast) String to Integer
+6.3k Grep : How to grep for strings inside binary data
+15.3k Golang : Validate hostname
+32.1k Golang : Copy directory - including sub-directories and files
+8.7k Golang : GMail API create and send draft with simple upload attachment example