selecting and deleting specific lines with condition
I have a set of data as below:
Quote:
HBOND SUMMARY
output to file HB_lowLyo_D_lipid_A_water_001_064.tbl,
data was sorted, intra-residue interactions are NOT included,
Distance cutoff is 4.00 angstroms, angle cutoff is 120.00 degrees
Hydrogen bond information dumped for occupancies > 0.00
Any pairs made from above numbers actually represents pairs in the 3rd and 6th field of each line in the data file.
What I want is to select the pairs from the data file made only by the numbers which are arranged at the outer most lines of the above number-molecule ordering.
To achieve this I have tried to write awk script as below to test to print out the line which I suppose to delete. But at this level I fail to select those line pairs.
Generally, by delete one means make a new file without. I am a bit confused in trying to see the objective. It may be a multi-pass project, to collect information, rearrange it to decide what to do, and then apply those results to the original. Where did it get hard?
If you notice the first line field 3 ($3), the residue number is 59 and in filed 6, the residue number is 19. Number 59 is in the outer most line and 19 is not according to the number-molecule arrangement. So this line should NOT be deleted.
If you notice the second line, field 3 ($3), the number 19 and in filed 6 ($6) the number is 24. Number 19 is not in the outer most line but number 24 is in the outer most line. This line also should not be deleted since NOT both the numbers are in the outer most lines.
If you notice the third line, field 3 ($3), the number is 16 and filed 6 ($6) the number is 17. Since both the numbers in this pair belongs to the outer most numbers, then this line should be deleted.
So after testing the criteria of the numbers to be in the outer most lines then that line should be deleted. This is what I need to achieve and this code simply does not work as I wanted.
So, This is a negative join. Semms like his approach should be good: you need to save the outer numbers in an array, and then as you go through the lines, look them up and decide if you want to copy. You could use while read in ksh/bash and put @ in IFS to split that field into two. You could decide each number's row mathematically (( (N%8) < 2 )).
What about when field 6 and 8 do not match? No different?
Last edited by DGPickett; 09-09-2011 at 06:02 PM..
Seems to me that you could use modulus to simplify the tests.
Your number x (assumed to be less than or equal to 64?)
if x % 8 = 0 it's in the right hand column
if x % 8 = 1 it's in the left hand column
then you just have the ranges
2<=x<=7
and
58<=x<=63
---------- Post updated at 05:31 PM ---------- Previous update was at 05:03 PM ----------
Ahhh...just realized, this test is wrong!
You can't test for the value of the array element this way, only that the subscript exists!
You could set your array differently instead of using set[i++] why not
break up the array and use set[n]? Then your test should work as you would have elements as follows:
Two other things I noticed...remove the semicolon after the test
and change "==" to &&
This is the biggest problem your script had other than trying to
use "in" to test the set values instead of the subscripts.
Thanks so much for your kind reply. The code perfectly works now as per my need. But additionally I want to ask you something related to this. At the end of the code I write "print" so that I want to see if the code selecting the lines which I dont want exactly. Now if I want to delete those selected lines, what command should I should use?
hi
i have a set of similar files. i want to delete lines until certain pattern appears in those files. for a single file the following command can be used but i want to do it for all the files at a time since the number is in thousands.
awk '/PATTERN/{i++}i' file (6 Replies)
Hello,
I have a file filled with dates, such as:
04-08-2011 message
04-08-2011 message
03-08-2011 message
01-08-2011 message
31-07-2011 message
24-07-2011 message
15-07-2011 message
13-12-2008 message
26-11-2007 message
And I want to delete those lines whose date is older than 10... (5 Replies)
I want to delete all lines from a file (orig_file) that contain the regex values (bad_inv_list)
I tried a for each loop with sed but it isn't working
for file in `cat bad_inv_list`;
do
sed '/$file/d' orig_file > pared_down_file.1
mv pared_down_file.1 orig_file
done
I've added... (2 Replies)
Hi,
I'am working under unix solaris
I have a text file with set of lines, each set of lines (BLOCK) have
three fixed lines :
Between SECND line and THEND we have N lines, N differ from a block to another
sample :
i have to make a script wich delete each 3 fixed lines if N=0... (3 Replies)
Hello experts,
I am new to this group and to 'SED' and 'AWK'. I have data (text file) with 5 columns (C_1-5) and 100s of lines (only 10 lines are shown below as an example). I have to find or select only the id numbers (C-1) of specific lines with '90' in the same line (of C_3) AND with '20' in... (6 Replies)
I need help on following script:
I need to print the lines which are in bold letters in separate file as
record
string("|") emp_name;
string("|") emp_id;
decimal("|") emp_salary;
string("|") emp_status;
string("\n") emp_proj;
end (1 Reply)
Hello,
I need to select the 3 lines above as well as below a search string, including the search string.
I have been trying various combinations using sed command without any success.
Can anuone help please.
Thanking (2 Replies)
I have a file which has some lines starting with a particular word. I would like to delete 5 lines before each such line containing that particular word.
eg:
line1
line2
line3
line4
line5
line6
"particular word"...
I would like to delete line2-line6 and all such occurences in that... (4 Replies)