You can use
find . -type f -name '*.c'
If you want to search in a directory other than your current directory, use
find /desired/path/to/search -type f -name '*.c'
instead.
To explain what this command does, the first argument is the path for find
to search for files in. Then -type f
tells find
to only consider regular files. -name '*.c'
tells find
to search for files whose names match the expression *.c
(*.c
is quoted to prevent the shell expanding the *
).
If you wish to search case-insensitively, replace -name '*.c'
with -iname '*.c'
(then files with .c
and .C
file extensions will both be found).
By default, find
will recursively search through all subdirectories of the directory provided. If you wish to limit the search depth, use the -maxdepth
option.
find
will only find files from.
on, so depending on what folder you are in you might not find anything. Try it asfind / -type f -name *.c
or change the/
to the start of whatever folder you think they are all in like~
or/usr
or/var
, etc. – Terrance Dec 30 '20 at 14:45