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
+7.1k Golang : Example of custom handler for Gorilla's Path usage.
+5.1k Golang : Generate Interleaved 2 inch by 5 inch barcode
+6.3k Golang : Combine slices of complex numbers and operation example
+9.4k Javascript : Read/parse JSON data from HTTP response
+5.1k Javascript : Shuffle or randomize array example
+13.2k Golang : Get constant name from value
+3.5k Java : Random alphabets, alpha-numeric or numbers only string generator
+7.9k Golang : How To Use Panic and Recover
+12k Golang : Flush and close file created by os.Create and bufio.NewWriter example
+30.1k Golang : How to redirect to new page with net/http?
+22.1k Golang : Read directory content with filepath.Walk()
+14.2k Golang : How to check if your program is running in a terminal