You don't have a field named CITY; you have a field named CITY followed by eight spaces. If you try to look for a value in the CITY field, it should fail because there is no CItY field.
With a comma separated data file, you don't have a city name of CHICAGO; you have a city name of CHICAGO followed by three spaces, and you don't have a city name of NEWARK; you have a city name of NEWARK followed by four spaces.
And, if someone entered the keys, CHICAGO followed by three spaces and STATE they should get IL followed by 7 spaces; not just IL.
And, if you have columns in the order CITY,STATE,COUNTY,STATE (which you said is possible) and the user gives keys NEW_YORK and STATE are you supposed to return the value in column 2, column 4, or both???
How are the keys supplied to your script?
What operating system and shell are you using?
What have you tried so far?
Is this a homework assignment?
Sorry for the confusion but there are no space in the data. I only put spaces to make it easier to understand. Here's how the data will appear:
Q. How are the keys supplied to your script? A value from first column and a column name
Ex: NEWARK & STATE, SEATTLE & COUNTRY, NEWARK & COUNTY
Q. What operating system and shell are you using? LINUX and ksh
So far, I have tried doing a egrep on both CITY and the value from the first row (ex: NEW_YORK or CHICAGO) to get two rows. But after that, I need to narrow down the value to a specific column name which can be either COUNTY or STATE or COUNTRY and here's where I am struck.
Moderator's Comments:
If you don't start using CODE tags (as required by forum rules) you may be banned from The UNIX & Linux Forums.
No, this is not a homework but rather I need to mine a metadata file to narrow down the value to a specific row and column.
Hope my explantion helps.
Last edited by Don Cragun; 06-21-2015 at 01:16 AM..
Reason: Add CODE tags, again.
Hi
I have a file like
a,1
b,2
d,3
a,2
b,3
c,7
Result Desired:
a,3
b,5
d,3
c,7
i.e on the bases of 1st field the addition is done of the 2nd field and result printed out. (3 Replies)
Hello,
Can someone please help me on this.:confused:
I have a file which has more than 1 million lines (XML file).
What I need is:
Search for "abcd" in the input file > output the result into a output.txt (colloum1)
Search for "efghi" in the input file > output the result in to... (3 Replies)
i have a file which has a column that is unique
i am intending to serach it and if it is there to remove the row.
the file looks like
ROLLNO,NAME ,SUB1,SUB2,SUB3,TOTAL,PERCENTAGE,RESULT
15 ,rig ,34 ,56 ,87 ,177 ,59 % ,PASS
23 ,wel ,45 ,76 ,56 ,177 ,59 % ... (0 Replies)
Scottn, m really sorry but i have not got my answer yet.
my concern is how to delete the row !!!
i have a file which has a column that is unique
i am intending to serach it and if it is there to remove the row.
the file looks like
ROLLNO,NAME ,SUB1,SUB2,SUB3,TOTAL,PERCENTAGE,RESULT... (9 Replies)
awk '{ gsub(/....=/,""); print }' want.dat >final.dat
the above awk command which removes all the chars before and including '=' on the entire row. --thats what it meant be.:)
but i need to remove text on column-wise on each row.
many thanks,
EM
---------- Post updated at 10:00 AM... (4 Replies)
Hi, as the title states i need to find a way to search a column for values great than 1000, and if it is, then delete that row.
An example
1 7.021 6.967 116.019 4 U 6.980E+07 0.000E+00 e 0 0 0 0
2 8.292 7.908 118.063 3 U 1.440E+07 0.000E+00 e 0 821 814 ... (3 Replies)
Hi,
I have a file containing 100,000 rows-by-120 columns and I need to compute for the standard deviation for each row. Any idea on how to calculate row-wise standard deviation using awk? My sample data looks like this:
input data:
23 35 12 25 16 17 18 19 29 12
12 26 15 14 15 23 12 12... (2 Replies)
I have a problem caught and need to discuss with all you guys.
I have a file containing a rows which are separated by “~”
For eg.
Server~321~UP~Linux~Member
121213~5778~Down~Unix~Provider
I want to use the grep which search the row on the basis of columns like the grep... (6 Replies)
I have 3 files. Each of those files have the same number of records, however certain records have different values. I would like to grep the field in ALL 3 files and display the output with only the differences in column wise and if possible line number
File1
Name = Joe
Age = 33... (3 Replies)