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
+4.3k Golang : The Tao of importing package
+6.1k Javascript : How to get JSON data from another website with JQuery or Ajax ?
+5.4k Golang : Test input string for unicode example
+13.3k Golang : How to shuffle elements in array or slice?
+5.8k Mac/Linux/Windows : Get CPU information from command line
+4.2k PHP : See installed compiled-in-modules
+39.2k Golang : How to count duplicate items in slice/array?
+7.9k Golang : Write multiple lines or divide string into multiple lines
+10k Golang : Create S3 bucket with official aws-sdk-go package
+10.3k Golang : Simple file scaning and remove virus example
+13.5k Golang : Find commonalities in two slices or arrays example
+6.1k Golang : Squaring elements in array