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
+20.8k Golang : Get password from console input without echo or masked
+7.9k Golang : HttpRouter multiplexer routing example
+35k Golang : Integer is between a range
+19.6k Golang : Accept input from user with fmt.Scanf skipped white spaces and how to fix it
+31.4k Golang : Convert an image file to []byte
+4.7k Golang : PGX CopyFrom to insert rows into Postgres database
+35.8k Golang : How to split or chunking a file to smaller pieces?
+11.1k Android Studio : Create custom icons for your application example
+41.2k Golang : Convert string to array/slice
+51.6k Golang : How to get time in milliseconds?
+17.2k Golang : Find smallest number in array
+17.2k Golang : Clone with pointer and modify value