Linux.com

Home Learn Linux Linux Documentation Using the Linux grep Command: Grepping a File Without Using cat

Using the Linux grep Command: Grepping a File Without Using cat

The grep command is a command that most Linux users learn early on, and many times they learn to use it via pipes (stdin). Because of this some Linux users just assume that grep can only be used with stdin; it’s ok, I was one of those too!

Before I continue with some grep tricks I want to clarify the basic grep usage.

Stop Doing This:

$ cat file.log | grep "something"
 something

Do This More:

$ grep "something" file.log
 something

 

Read more at bc-log
 

Comments

Subscribe to Comments Feed
  • Chris Said:

    Thanks, I need to get a good kick in the leg about this every so often, been using the command line for more than a decade and I still pipe into grep :( I think I need to print this out and stick it up on my wall.

Upcoming Linux Foundation Courses

  1. LFD211 Introduction to Linux for Developers
    08 Dec » 09 Dec - Virtual
    Details
  2. LFS220 Linux System Administration
    08 Dec » 11 Dec - Virtual
    Details
  3. LFS520 OpenStack Cloud Architecture and Deployment
    08 Dec » 11 Dec - Virtual
    Details

View All Upcoming Courses

Become an Individual Member
Check out the Friday Funnies

Sign Up For the Linux.com Newsletter


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board