Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

share|improve this question
1  
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

 
discard

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.