Artificial intelligent assistant

Why does `grep fil*` fail? I found `echo file|grep fil*` fails, but `echo abcd|grep abc*` succeeds. I don't understand it, can someone explain?

There are two problems with your example.

The primary one is that you're assuming that regular expressions work the same as glob patterns) in that `*` is a wildcard meaning "any sequence of characters." In regular expressions, `*` means "any number of the previous atom" instead, so `fil*` means `f` followed by `i` followed by zero or more `l` characters. You need to say `grep fil.*` to get the intended meaning: `.` means "any single character, so that `.*` means "any sequence of characters."

The lesser problem is that you're using unquoted special characters that mean something under glob rules, which means the shell could interpret them. If you had any files in the local directory matching the glob patterns `fil*` or `abc*`, the shell would expand them, so `grep` would get the expanded file names as a pattern, not the intended RE. Whenever you're using such characters on the command line, you should quote them: `echo file | grep 'fil.*'`.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 598e70604df35f5e03db44da46e45e6a