Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.