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
+5.8k Golang : Markov chains to predict probability of next state example
+8k Golang : Trim everything onward after a word
+5.3k Golang : The Tao of importing package
+15.3k Golang : How to check if IP address is in range
+6.2k Golang : Extract XML attribute data with attr field tag example
+23.6k Golang : minus time with Time.Add() or Time.AddDate() functions to calculate past date
+5.5k Golang : Stop goroutine without channel
+11.5k Golang : Change date format to yyyy-mm-dd
+11.6k Golang : Fuzzy string search or approximate string matching example
+6.7k Golang : Derive cryptographic key from passwords with Argon2
+26.8k Golang : Convert file content into array of bytes
+28.8k Golang : Detect (OS) Operating System