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
+9.4k Golang : Simple File Server
+6.3k Golang : Create zip/ePub file without compression(use Store algorithm)
+4.2k Golang : Get FX sentiment from website example
+8.4k Golang : Launch Mac OS X Preview (or other OS) application from your program example
+7.7k Golang : Gorilla web tool kit schema example
+3.5k Golang : Valued expressions and functions example
+9.5k Golang : Fix go.exe is not compatible with the version of Windows you're running
+7.9k Golang : HTTP Routing with Goji example
+5.2k Golang : How to get capacity of a slice or array?
+6k Golang : Transform lisp or spinal case to Pascal case example
+8k Golang : Inject/embed Javascript before sending out to browser example
+6.5k Golang : Detect sample rate, channels or latency with PortAudio