Artificial intelligent assistant

find and grep pipeline returning nothing I have files named `lect1.txt`, `lect2.doc`, and `lect3.doc`. I want to get a file which is a `.txt` file, and contains `lect` as the filename. I tried find *.txt | grep lect* and it returned nothing. but when I did find *.txt | grep "lect*" it returned `lect1.txt`. What's the difference between these two expressions?

`grep` searches for the first argument (the pattern) in the files passed on the command line **or** `stdin` if no files are passed.

Without the quote your shell will expand `lect*` to all the files in the directory that begin with `lect`. Your command will then be:


grep lect1.txt lect2.doc lect3.doc


which means _search for the text`lect1.txt` in both `.doc` files_. Unless one of the `.doc` file has the phrase `lect1.txt` within it, it will return nothing. To be more precise, it will look for `lect1` followed by any character (the `.`) followed by `txt`, so it would also find `lect1-txt` and `lect1xtxt` etc)

In your second example, you've quoted `"lect.*"` so that the shell doesn't expand it and it is passed as is to `grep`. With only a pattern passed as an argument, `grep` will search the filenames passed in `stdin` for the pattern, which is what you are after I believe.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 3b14785f1f0c36c785ea98f2681c12f3