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!
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.
Click Here to receive this Complete Guide absolutely free.
sed -rn 's#^. ([[:digit:]]+\.[[:digit:]]+)(.*)(length:)([[:space:]])([[:digit:]]+)(.*)#\1,\5#p' trace.txt
I knew awking this thing would take me forever - thanks ghostdog for posting that. (When I search internet for help with this stuff, your name always comes up somewhere along the line )
So I looked at sed instead as I seem to have better success with sed; and thanks to syg00, finally figured out I was missing the -r and the trailing p ... now it works.
EDIT: P.S. - while the initial scripting method earlier may have been slow and had overhead, it was probably more educational than any of these things.. OP seems pretty new to this sort of thing. A simple script is less cryptic than this stuff and probably easier to understand :/
Last edited by GrapefruiTgirl; 07-29-2010 at 12:12 PM.
Thanks for the help guys. I will try out each one, though, as GrapefruiTgirl mentioned, the console command prompts of sed and awk are all kind of cryptic to me for now.
Does anyone know of any good tutorials for learning how to parse with sed, grep, and awk?
Which one of these are preferred for what types of applications?
The key to successful usage of ANY of these tools, is to learn "Regular Expressions", otherwise called "regexps". Those are what allow any of these tools to be able to identify the chunks of data that you want them to. Without knowing regular expressions, doing anything beyond the simplest parsing, is pretty much impossible.
I can't really put into words which of sed or awk is better for what task. Each task is different, and after you are comfortable to some degree with both, you tend to sort of have a feeling that one or the other is better. For me, since I know less awk than sed, I often try to do a job with sed first, because usually I can do it quicker - but this is not always practical nor productive and so if sed won't easily do a job, awk is the next thing on the list.
Grep is more for just finding text or data in files, but not so much for doing any particular processing of the data - only for filtering it and showing it, or showing where it is.
Sed is a stream editor - it operates line-by-line on streamed data which is fed into it, processing the data and outputting the results on the other end.
AWK is.. I don't know how to describe AWK.. It's like sed, but different, larger, perhaps more powerful & complex, and it can also easily do math computations and bitwise operations, that are klunky or impractical to do with sed.
There are loads of tutorials of all sizes & shapes, all around the 'net, on each of these tools. I haven't got a particular link(s) handy to recommend, but likely other members will have some links to their favorite tutorials to share with you. Just remember, learn & understand regexps first; start at the bottom and work up.