-3

I was wondering if there is a way to find files that end with .c using /\.c/. How would I do that?

I have tried ls -l /\.c/ but it doesn't work.

4
  • 1
    What does using /.c/ mean to you? Commented Oct 11, 2020 at 17:24
  • i dont know either. my professor said we can find files that end with anything for example .c using this command '/\.c/' but I don't know how to use it @ArkadiuszDrabczyk Commented Oct 11, 2020 at 17:31
  • 1
    All shells allow glob patterns, like *.c, to find such files. So ls -l *.c should do what you want. /\.c/ looks like a search expression used by an editor like vi. Commented Oct 11, 2020 at 17:44
  • Thanks it works now @NickD Commented Oct 11, 2020 at 18:03

1 Answer 1

2

Try this instead: find . -name '*.c'
or with more details on the found files: find . -name '*.c' -ls

2
  • 3
    Seems awfully complicated for ls *.c Commented Oct 11, 2020 at 20:52
  • I assumed @Beakal Begashaw wants to find all files with .c extension, including in the sub-directories of the search path. If he wants to find the .c files only in in the current directory, indeed, your answer is more concise. Commented Oct 12, 2020 at 11:20

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.