Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

grep never returns anything unless I put a * or . on the end - why?

Tags:

linux

grep

If I put a * or . on the end of a grep command, I will get results instantly. However, if I don't, the command never returns anything.

I'd appreciate it if someone could tell me why, or direct me to a source that includes that information! Looking online all, everything talks about searching FOR a period or asterisk in your search. Most examples don't include a * or ., and the ones that do don't tell me what they're actually doing.

Thanks!

like image 958
epch Avatar asked Oct 28 '25 13:10

epch


1 Answers

Without a list of files to search, grep reads stdin by default. e.g.

$ grep -o a..
This appears to freeze, but is actually just waiting for input
app
ars
act
all
ait
^D

By the way, grep’s more useful cousin, ack, does what you’d expect. :)

like image 156
Ry- Avatar answered Oct 31 '25 03:10

Ry-



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!