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
+19.8k Swift : Convert (cast) Int to int32 or Uint32
+10.6k Golang : Natural string sorting example
+18.3k Golang : Write file with io.WriteString
+31.8k Golang : Validate email address with regular expression
+5.4k Fix fatal error: evacuation not done in time problem
+9.4k Golang : How to generate Code 39 barcode?
+5.8k Golang : Grab news article text and use NLP to get each paragraph's sentences
+10.1k Golang : Simple Jawi(Yawi) to Rumi(Latin/Romanize) converter
+17.7k Golang : Put UTF8 text on OpenCV video capture image frame
+6.5k Golang : Output or print out JSON stream/encoded data
+11.4k Golang : Calculations using complex numbers example