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.
I have a program that prints its output to standard out. What I want to do is look at this data and grab pieces of information from it as it comes.
More specific, if I redirected the output to a file, the last line would be of form:
Final graph has (\d+) nodes and n50 of (\d+) max (\d+)
and I want to grab these 3 numbers and put them in a file. Now, do I have to redirect the output to a file then read through each line or can I just say look at the last line (I'd like to know how to do both for future reference) or can I do it directly from the standard output?
From what I understand of what you want to do, you want to pass the data stream out stdio unchanged but extract the information from it that you need. One way of doing this is to use the "tee" command which is like a tap between two pipes (|). The argument to tee is a file. The standard input is passed on to the standard output and to the file or files which are listed as arguments. The file argument could be a fifo special file, and the fifo file could be used as the file input argument of a sed or awk command running in another script or in background subprocess of the same script.
sed -f extractnodes.sed nodes >extracted_nodes.cvs &
<program generating your data stream> | tee nodes | <program processing your data stream>