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.4k Golang: Prevent over writing file with md5 hash
+9.7k Golang : Get currencies exchange rates example
+10.4k Golang : Simple file scaning and remove virus example
+6.5k Golang : Individual and total number of words counter example
+7.1k Golang : Append and add item in slice
+8.5k Golang : Convert(cast) string to int64
+24.7k Golang : missing Mercurial command
+14.9k Golang : Get sub string example
+4.4k Golang : Issue HTTP commands to server and port example
+8k Golang : Populate or initialize struct with values example
+4.1k HTTP common errors and their meaning explained
+11.2k Golang : Add ASCII art to command line application launching process