I want to search only in my files, contains only .txt and .c

This doesn't work for me
ls | grep .txt | grep .c

I want the ls and grep .txt, .c

??Thanks??

Recommended Answers

All 3 Replies

From your question above I only managed to understand that, you want to display all the files with '.c' and '.txt' extensions in the current directory . Am I right?
if so then you can do like this in bash:

ls *.c *.txt

i.e ls filetypes. '*' is just a wildcard specifier.
If this is not what yo're looking for then you may have to elaborate your question.

From your question above I only managed to understand that, you want to display all the files with '.c' and '.txt' extensions in the current directory . Am I right?
if so then you can do like this in bash:

ls *.c *.txt

i.e ls filetypes. '*' is just a wildcard specifier.
If this is not what yo're looking for then you may have to elaborate your question.

Yeah ! it works thanks! sorry for my spelling! =S

This is known as file globbing and has slightly different behavior than regular expressions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.