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.9k Golang : Comparing date or timestamp
+8.2k Golang : Get all countries phone codes
+6.2k Golang : Convert Chinese UTF8 characters to Pin Yin
+17.9k Golang : Read data from config file and assign to variables
+4.8k Linux : sudo yum updates not working
+9.2k Golang : Get SPF and DMARC from email headers to fight spam
+9.5k Golang : Create unique title slugs example
+8.7k Golang : Convert(cast) []byte to io.Reader type
+20.1k Golang : Count JSON objects and convert to slice/array
+16.2k Golang : How to reverse elements order in map ?
+20k Golang : Archive directory with tar and gzip
+16.5k Golang : How to extract links from web page ?