This is a discussion on using sed to delete everything except needed patterns within the Shell scripting forums, part of the Development/Scripting category; I have floating point data (193 rows & 2 column in a file from which i would like to delete ...
|
|||||||
| Register | FAQ | Members List | Calendar | Forgotten your password? | Mark Forums Read |
|
|||
|
I have floating point data (193 rows & 2 column
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 ' pattern1/p' ' pattern2/p' ..... 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(row .......? |
| Sponsored Links | ||
|
|
|
|||
|
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 ? |
|
|||
|
data reads different in C program
I wrote a Cprogram to just read the output file created using our above sed lines. the output file was 12703 bytes after removing ^M (discussed in our forum topic 'contents of file') the total no of floating pt data is 1760. So diving file size by 1760, i get 7.2176 bytes per each data. i dont know how many bytes shell script used to represent floating pt. I declared malloc for double data. then read 7 bytes and printed it..........some differnt data got printed. then i tried reading 6 bytes & 4 bytes still it did not work. does this mean the output file created by shell is in a different format?? |
|
|||
|
data reads different in C program
I wrote a Cprogram to just read the output file created using our above sed lines. the output file was 12703 bytes after removing ^M (discussed in our forum topic 'contents of file') the total no of floating pt data is 1760. So diving file size by 1760, i get 7.2176 bytes per each data. i dont know how many bytes shell script used to represent floating pt. I declared malloc for double data. then read 7 bytes and printed it..........some differnt data got printed. then i tried reading 6 bytes & 4 bytes still it did not work. does this mean the output file created by shell is in a different format?? |
|
|||
|
Quote:
ya i acutally got the solution. shell wrote the output file as characters. so if data was 16.2345 then the seven characters each had one byte and that y my file size was about 1760x7.something(decimal) data in the c code i was reading float data using read(fp,buf,sizeof(float)) and this was giving me trash. Now i changed the code to Code:
while(!feof(fp)){
fscanf(fp,"%f",&f);
/*printf("%f\n",f);*/
fwrite(&f,sizeof(float),1,fout);
}
Can give me a small C program to draw a graph. As i mentioned in the beginning, i have 2 columns of data and i just want to plot a graph in C with colm 1 as x axis and all the different column 2's from all the .txt files as y axis. Note: column 1 data is same in all .txt files. |
|
||||
|
Okay try out following urls
Plplot online doc: http://plplot.sourceforge.net/docboo...lot-html-5.5.3 An example of Plplot: http://plplot.sourceforge.net/examples/index.html Try it and lemme know it... |
![]() |
| Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| postfix + google = headache. your help needed | TECK | Linux software | 2 | 02-26-2008 05:45 PM |
| equivalent command needed in both Solaris and Linux | bglassberg | Linux software | 1 | 02-21-2007 09:36 AM |
| Guidance needed | jithendra | Linux software | 2 | 11-07-2006 10:26 AM |
| Help needed regarding bash scripting of a webpage | chris411 | Shell scripting | 2 | 09-07-2006 11:40 AM |
| Help needed regarding bash scripting ---full description | chris411 | Shell scripting | 1 | 09-07-2006 05:21 AM |