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
+10.7k Golang : Split strings into command line arguments
+10k Golang : Fix fmt.Scanf() on Windows will scan input twice problem
+12.4k Golang : Activate web camera and broadcast out base64 encoded images
+7.7k Golang : Accept any number of function arguments with three dots(...)
+8.2k Golang : How to get ECDSA curve and parameters data?
+16.1k Golang : Multi threading or run two processes or more example
+15.5k Golang : How to generate QR codes?
+18k Golang : How to run your code only once with sync.Once object
+12.9k Golang : Get uploaded file name or access uploaded files
+5.7k Golang : Find the shortest line of text example
+21.1k Golang : Read a file into an array or slice example
+35k Golang : Convert date or time stamp from string to time.Time type