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
+15.1k Golang : Get sub string example
+26.7k Golang : Record voice(audio) from microphone to .WAV file
+22.6k Golang : Fix type interface{} has no field or no methods and type assertions example
+5.2k Golang : Measure execution time for a function
+5.3k Golang : Convert Chinese UTF8 characters to Pin Yin
+7.1k Golang : Gomobile init produce "iphoneos" cannot be located error
+23.1k Golang : Call function from another package
+9k Golang : Sort and reverse sort a slice of integers
+24.9k Golang : Get executable name behind process ID example
+10.8k Golang : Convert(cast) float to int
+11.4k Golang : Extract part of string with regular expression
+7.1k Golang : Check from web if Go application is running or not