Input File:-
The value in Column 3 should determine that among columns $7(SMS),$8(EMAIL),$9(AO),$10(Mail),$11(P),$12(N) and $13(cell), which column will have a non-zero integer value and which will have value zero.
eg.
example 1- if column 3 has value E then code should check only column 7,9,10,11,12,13 and sum of these columns (7+9+10+11+12+13) should be zero . If it is Zero then add GOOD else add WARNING to Newcolumn. like in row 1 in the above file the sum of the 7,9,10,11,12,13 columns is zero so added Good in the out put file. example 2 -if Column 3 has value SE then code should only check columns 9,10,11,12,13 and sum of these columns (9+10+11+12+13) should be zero.If it is Zero then add GOOD else add WARNING to Newcolumn. like in row 4 the sum of columns 9,10,11,12,13 is not zero so added warning to the output file.
Now, single character value like E, S, A etc is fine but when there is a string like SE or AM or EAMS then there is a problem.
Like row 5 column 3 has values EAMS so it should only check column 11,12,13 and if those columns are greater then zero then add WARNING to Newcolumn.
Column 3 can be combination of any predefined values in no particular sequence eg. EM,ES,E,S,M,EAMS,EMAS,EP,P,SEC,SEA and more.
Conditions based on which code will decide GOOD or WARNING:-
I know its is very confusing. Please help. For single values(can be E or ES or EAM or ...) i am using below code. I have taken E as an example.
Desired OUTPUT
Last edited by Nina2910; 09-28-2016 at 09:03 PM..
Reason: Fixed output file row3
You are correct. This is very confusing. You show us code, but do not tell us if it is doing what you want for the single case it seems to try to handle, and for all of the other cases you don't even say what output you do want. How do you expect us to help you write code if you don't clearly explain what that code is supposed to do?
Please show us the exact output that you want your script to produce for the sample input you provided, and explain in detail what output is supposed to be produced for any given value found in field 3 in your input file.
Is there supposed to be a header line in the output produced? If so, what header is supposed to appear in the output?
This User Gave Thanks to Don Cragun For This Post:
@Don. Thank you for reading such a long post and your feedback. I tried to edit it.Please let me know if it is readable to you now.Otherwise I will try to edit it more
@Don. Thank you for reading such a long post and your feedback. I tried to edit it.Please let me know if it is readable to you now.Otherwise I will try to edit it more
Hello Nina2910,
Could you please try following and let me know if this helps you.
Output will be as follows.
Also not sure how you output shown in last row and 3rd last row has warningin them as I could see their 11st, 12th and 13th field's sum is 0 only.
If it was a typo then please try above and let me know if this helps. Also rushing to somewhere so will add non-one liner form little later. EDIT: Adding a non-one liner form of solution too now. EDIT2: Improving the solution above by putting logic where once the match found in any of if condition then it shouldn't execute further conditions to save time of execution here.
Thanks,
R. Singh
Last edited by RavinderSingh13; 09-28-2016 at 06:46 AM..
Reason: Adding a non-one liner form of solution too successfully now.
This User Gave Thanks to RavinderSingh13 For This Post:
Please STOP changing your posts. If you keep updating post #1 in your threads, no one can follow the conversation we are having trying to get a clear specification of your problem. In the future, please stop and think about what you are asking us to help you do before you submit your first post!
If you need to add more details, do so in subsequent posts; don't keep changing post #1 in a thread. During the time that I have been trying to compose this message, you have edited post #1 at least a dozen times. How can you expect anyone to help you if you keep changing the description of what you want done!
You have now told us what columns need to be added when column 3 is one of A, C, E, M, N, P, S, SE, or EAMS. And you have told us that column 3 can have numerous other values with absolutely no specification of what is supposed to happen in those cases. (Unless you have changed things again and I missed it.)
Please give us a clear description of what needs to be done and then ask for help. I'm tired to trying to keep up with a constantly changing, incomplete description of what you want done.
You constantly state that a list of fields have to be added, but from your sample data that seems like a waste of time. Since none of your input fields seem to have negative values, can your script just add warning (which is what is in your description) or Warning (which is what is in your code) or WARNING (which is what is in your sample output) instead of Good (which is in your description) or Goodd (which is what is in your code) or GOOD (which is what is in your sample output) when any of the specified fields contains a non-zero value (instead of adding them all together and then looking for a non-zero sum)?
you have to repeat the read color coding for other checks as well
---------- Post updated at 12:59 AM ---------- Previous update was at 12:58 AM ----------
@Don... Sorry for numerous updates . Trust me I was just trying to make it as clear as possible and I am done updating .. Sorry for inconvenience today.
I would like to compare values in column 8, and grep the ones where the different is > 1, columns 1 and 2 are the key for array.
Every 4 rows the records values in columns 1 and 2 changed. Then, the comparison in the column 8 need to be done for the 4 rows everytime columns 1 and 2 changed
... (4 Replies)
Dear Unix experts,
I have got a file where I would like to compare the values of second column if first column is same in such a way that the difference between the values is >50. If not, I would like to discard both values.
For example, my input file looks like -
comp275_c0_seq2 73... (7 Replies)
Hi all !
If there is only one single value in a column (e.g. column 1 below), then return this value in the same output column.
If there are several values in the same column (e.g. column 2 below), then return the different values separated by "," in the output.
pipe-separated input:
... (11 Replies)
- I have two files (File 1 and File 2) and the contents of the files are mentioned below.
- I am trying to compare the values of Column1 of File1 with Column1 of File2. If a match is found, print the corresponding value from Column2 of File1 in Column5 of File2.
- I tried to modify and use... (10 Replies)
Hi,
I have a table in unix from which i want to read the contents line by line, then filter out the values from 6th column one by one and compare it a fixed value.
How to do this? (7 Replies)
I would like to compare the values of 2nd column of consecutive lines of same file in such a way so that if the difference between first value and second value is more than 100 it should print complete line else ignore line.
Input File
==========
PDB 2500
RTDB 123
RTDB-EAGLE 122
VSCCP 2565... (4 Replies)
Hi All,
I have two files
file1:
abc,def,ghi,5,jkl,mno
pqr,stu,ghi,10,vwx,xyz
cba,ust,ihg,4,cdu,oqw
file2:
ravi,def,kishore
ramu,ust,krishna
joseph,stu,mike
I need two output files as follows
In my above example, each row in file1 has 6 fields and each row in file2 has 3... (1 Reply)
Hi All,
I have two files
file1:
abc,def,ghi,5,jkl,mno
pqr,stu,ghi,10,vwx,xyz
cba,ust,ihg,4,cdu,oqw
file2:
ravi,def,kishore
ramu,ust,krishna
joseph,stu,mike
I need two output files as follows
In my above example, each row in file1 has 6 fields and each row in file2 has 3... (1 Reply)
Hi,
I am new to unix and I need help in solving below mentioned issue, really appreciate ur help.
I have a file
sam, john, 2324, 07142007
tom, thomson, 2343, 07142007
john, scott, 2478, 07142007
its a comma delimited file, I need to extract the last column from each line and this... (4 Replies)