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. LFD320 Linux Kernel Internals and Debugging
    04 Aug » 08 Aug - Virtual
    Details
  2. LFD405 Embedded Linux Development with Yocto Project
    04 Aug » 07 Aug - Santa Clara, CA
    Details
  3. LFD312 Developing Applications For Linux
    18 Aug » 22 Aug - 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