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
+14.6k Golang : Find network of an IP address
+10k Golang : Translate language with language package example
+7.7k Golang : Set horizontal, vertical scroll bars policies and disable interaction on Qt image
+8.6k Golang : How to check if input string is a word?
+7.8k Golang : get the current working directory of a running program
+24.8k Golang : How to print rune, unicode, utf-8 and non-ASCII CJK(Chinese/Japanese/Korean) characters?
+8.7k Golang : Convert(cast) []byte to io.Reader type
+16.6k Golang : Get IP addresses of a domain name
+7.8k Golang : Convert(cast) io.Reader type to string
+6.5k Golang : Detect face in uploaded photo like GPlus
+11.7k Golang : Simple file scaning and remove virus example
+10.1k CodeIgniter : Load different view for mobile devices