Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!

Notices

Welcome to LinuxQuestions.org, a friendly and active Linux Community.

You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!

Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.

If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.

Having a problem logging in? Please visit this page to clear all LQ-related cookies.

Introduction to Linux - A Hands on Guide

This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.

Hello Friends,
Could anybody provide me links to any online available document or tutorial or blogs about "awk vs grep". I have though searched over Internet, but couldn't find anything useful.
I am looking for some tutorials having some advanced comparision between these two commands. My goal is to avoid using multiple filters again and again in commands & shell scripts. Looking for something that is short & sweet like awk.
Thanks for your help!

The difference is that grep is a simple tool for searching patterns in text, while awk is an advanced scripting language that alows you to process and modify text in practically any way you want. Anything that you can do with grep can be done with awk, too. If I over-simplified it: if you know awk, you don't even need grep. The only reason to use grep is when the grep command happens to be shorter.

As millgates mentioned, they are two very different things. AWK is an interpreted programming language. Grep is a plain utility that does simple pattern matching. To get started with awk, just search for awk and/or tutorial or howto. That will bring up many useful guides like this one: http://www.grymoire.com/Unix/Awk.html

Probably the difference will become more obvious if you try using them. The next step up from awk would be perl.

As already suggested, you will not find a comprehensive comparison of AWK and GREP---they are totally different things. I can offer one comparison: The average person should be able to learn GREP in about 5 minutes. Learning AWK might take closer to 5 DAYS.

It's interesting in that it shows implementations of grep capabilities using awk. That can be done but, awk is far more powerful and is usually used to manipulate the data. Whereas grep can only find a pattern.

Sorry to re-open a solved thread. I am aware what awk and grep is and what do they do. But my motive is to find a tutorial or lession where I can get situations in which grep can be rerplaced with awk. Because awk can be helpful in doing multiple task in a single cmd, whereas grep can't!

Sorry to re-open a solved thread. I am aware what awk and grep is and what do they do. But my motive is to find a tutorial or lession where I can get situations in which grep can be rerplaced with awk. Because awk can be helpful in doing multiple task in a single cmd, whereas grep can't!

Reading the whole grep manual it's actually easy to see the limits of grep and where you'd start using awk. It's just like using a ladder, if grep is not enough, use awk (assuming you won't consider sed and egrep). If awk is not enough, use larger languages like Perl, Ruby, or Python, etc.

Also, it's always easier to learn by the problems you encounter rather than learning by available examples, but if you want to learn ahead there are many examples around the web for that. It's really easy to find them actually. Then as you read them you just have to use a reference (like the Gawk manual) to see how or why they work then that's how you learn.

---- Add ----

Of course we don't only use Awk because Grep is no longer able to handle the task(s). Some just prefer to use Awk because the resulting code is cleaner or simpler, and sometimes it's just a matter of favor, taste or preference regardless if it has a sensible reason or not.

A long time ago, when I was beginning a new career sitting in front of a Unix computer, and finding that it had a huge range of tools that were good for exploring, handling and manipulating data in text format, and also finding that I had a growing need to do so, I spent a lot of money on a book called

This substantial book will give you an overview of all the major *ix text editors and processing tools. It will put them in context in relationship to each other.

If you have a quick project you need to stamp "completed," this book will be too much for. If you have a personal or professional need to discover and work in this area, then it is a treasure chest.

It is the closest thing to the tutorial you originally asked for as I have ever seen, but this is not the sort of tutorial that is an hours work: this is one for weeks and months, even if (like me) you have no need to really use the Unix typesetting tools.

I can say that I built a career on this book, the Awk Programming Language book, some books on administration --- and the Unix manuals (man pages).

(I don't know what edition is online. You may, for practical purposes, need to consult man pages and other sources for up-to-date options and capabilities)