Quote:
Originally Posted by
Don Cragun
I asked "
How are the keys supplied to your script?" You responded "
A value from first column and a column name
Ex: NEWARK & STATE, SEATTLE & COUNTRY, NEWARK & COUNTY"
That response is an answer to the question "
What is supplied to your script?", not "
How".
- Is your script passed two operands?
- Is your script passed one operand with a literal <space><ampersand><space> between the two keys?
- Are the values read from a file? (If so what is the file format?)
- Can more than one pair of keys be supplied to your script to be processed during a single invocation of your script?
- Exactly what format should be used for the output?
- Are the keys supposed to be included in the output?
- If more than one pair of keys are input, is the output supposed to be a single line or one line for each pair of keys?
- Is the data built into the script or is it in a file?
- If the data to be processed is in a file, is the pathname of the file built into the script (If so, what is that pathname?), or is it passed in as an option argument (If so, what is the option letter and what is the default pathname if no option is provided?), or is it passed in as an operand?
Please help us help you. Don't make us guess at what you're trying to do. Show us that you have thought about the design of your script and aren't just asking us to not only guess at how your script is supposed to work but also what the output is supposed to look like.
And, PLEASE, use CODE tags where appropriate in your posts.
1. Is your script passed two operands?
Yes, I get two parameters passed.
2. Is your script passed one operand with a literal <space><ampersand><space> between the two keys?
No. I get two parameters passed.
3. Are the values read from a file? (If so what is the file format?)
Yes, it is a comma seperated file as shown in my prior post.
4. Can more than one pair of keys be supplied to your script to be processed during a single invocation of your script?
No, I only get one pair of keys.
5. Exactly what format should be used for the output?
I just need to fetch the value which can assigned to a variable.
6. Are the keys supposed to be included in the output?
No
7. If more than one pair of keys are input, is the output supposed to be a single line or one line for each pair of keys?
Only one pair of keys are input.
8. Is the data built into the script or is it in a file?
Data is an external file.
9. If the data to be processed is in a file, is the pathname of the file built into the script (If so, what is that pathname?), or is it passed in as an option argument (If so, what is the option letter and what is the default pathname if no option is provided?), or is it passed in as an operand?
Data is a pathname. For sake of simplicity, pls assume that data is residing at /tmp/metadata.csv
My solution so far has been:
$ cat /tmp/metadata.csv | egrep "NEWARK|COUNTY"
CITY,COUNTY,STATE,COUNTRY
NEWARK,ESSEX,NJ,USA
Where /tmp/metadata.csv is the file path.
NEWARK is the first parameter
COUNTY is the second parameter
Now, I am trying to use awk to get my final output as ESSEX.
Hope this explantion helps.
Thanks again for your questions.