Take the 2-minute tour ×

Is it possible to print to the console all file content using only grep command? (wihtout cat, less, echo, more...)

share|improve this question
There is, but I'm not sure why you'd want to, as even in the optimum cases @Ignacio describes it'd be slower than cat. –  Shadur Sep 28 '11 at 8:02
@Shadur Looks like exploiting a bug in/with grep must be the reason... Interesting. –  rozcietrzewiacz Sep 28 '11 at 8:57
no, I'm just playing a game which is a simulator for linux administration. I need to look what's in a file but I have only 11 commands - grep is among them. –  Sergey Sep 29 '11 at 4:08
add comment

1 Answer

up vote 8 down vote accepted

Of course. Every line has a beginning.

grep '^' file.txt
share|improve this answer
'' (the empty pattern) also works since the empty string matches everywhere as well. –  jw013 Sep 28 '11 at 7:12
add comment

Your Answer


