ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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 floating point data (193 rows & 2 columns) in a file from which i would like to delete every row except some required rows. I have written a test.sed file which had
and after that used
sed -f test.sed input_file > output
however this was not appending the whole input file to the output file but my required patterns were written twice in the output.
How do i delete all other lines(rows).......?
thanx for the reply. i tried the command u said ( grep -v.....) but it copied the whole input file to the output file. It might have been because test.sed had a /p option in it.
but this one seems to work
sed -n -f test.sed input_file > output_file
as it did not print anything else other than the pattern in test.sed (with th /p option) and redirected it to the output file.
what do u say about this
sorry if my phrase was confusing........
I have a file with 2 columns of floating pt. data ( many rows). i only want some rows and not all. And this selection is based on the first column values. So if type in all the first column values "that i need" into a test.sed file then how can i remove all other rows which are not necessary for me? That was my question. I did use the /p option in the test.sed file. as in my first post. so the output file had both the required data and the unrequired data but with /p option the required data got repeated. This only made my problem worse.
sed -n -f test.sed input_file > output_file
seems to have solved the problem ( with -n option).
Thats for what happened.
Now in the output file i dont want the data placed line by line. ( when i use less outputfile or vim outputfile i find a ^M after each line.^M stands for ENTER/return) I want them placed next to each other without ^M. I tried some commands but they did not work out.
yes the inputfile is a .txt file from which i am trying to coming with the data that i need. the ^M is not there when i try "less file.txt" but in the output file is do see ^M after every set of values that i obtained by the sed operation mentioned above.
got a new problem, in my test.sed file i used the pattern /0.400/p to get the two columns with 0.400 in column one. however i also have a 14.400 in the input file.
now the 14.400 and its corresponding column two also got copied to the output file. This also happened with two other values........is there a way that i can select only 0.400 and not 14.400 or 3.400 ?
ok the input file looks like this........posting only some samples not possible to post all........
now i wrote the test.sed as
now i use some thing like this : sed -n -f test.sed inputfile > outputfile
now the outputfile is like this
Now from the input and test.sed my output should have only one (2.296 50.4684) but i have two? reason: because i am also looking for a pattern with .468 so sed also considered the .468 of the 50.4684 of this value and printed that line twice. now my search critirea is only column one of the data. Not only that sed is considering repeated patterns in column one also........
hope u understand the question