JustRandomName
February 11th, 2006, 06:13 PM
Hi,
I am having a few problems with a shell script, maybe you guys can help me out.
I have a file called details with a list of ID and names like so:
24100321 John Smith
24100123 Jayne Doe
24100124 Dave Jones
24101124 Laura Taylor
24100111 Gary Johnson
24100222 Simon Smith
...etc...
I also have a file called results like so:
24100222
01 10
02 9
03 8
04 8
05 6
06 6
24100124
01 6
02 2
03 6
04 4
05 6
06 1
24100321
01 4
02 5
03 4
04 6
05 1
06 1
24100123
01 1
02 1
03 1
04 4
05 10
06 2
How would I match the names to the ID? I think it has something to do with join.
At the minute I am doing:
join -a1 results details > tempfile
This is matching up some id's with names (Only Jayne Doe and John Smith from the sample data), but not all of them. I suspect I have to somehow sort the data first... How can I tell sort to treat every seven lines as one record?
Also how would I get the ones that have not been matched up to be output too? something like this@
24100321 John Smith
01 4
02 5
03 4
04 6
05 1
06 1
24100123 Jayne Doe
01 1
02 1
03 1
04 4
05 10
06 2
Missing Laura Taylor
I have tried with by using the -e argument with join like so:
join -a1 -e "Missing" results details > tempfile
But it seems to get ignored.
Thanks
I am having a few problems with a shell script, maybe you guys can help me out.
I have a file called details with a list of ID and names like so:
24100321 John Smith
24100123 Jayne Doe
24100124 Dave Jones
24101124 Laura Taylor
24100111 Gary Johnson
24100222 Simon Smith
...etc...
I also have a file called results like so:
24100222
01 10
02 9
03 8
04 8
05 6
06 6
24100124
01 6
02 2
03 6
04 4
05 6
06 1
24100321
01 4
02 5
03 4
04 6
05 1
06 1
24100123
01 1
02 1
03 1
04 4
05 10
06 2
How would I match the names to the ID? I think it has something to do with join.
At the minute I am doing:
join -a1 results details > tempfile
This is matching up some id's with names (Only Jayne Doe and John Smith from the sample data), but not all of them. I suspect I have to somehow sort the data first... How can I tell sort to treat every seven lines as one record?
Also how would I get the ones that have not been matched up to be output too? something like this@
24100321 John Smith
01 4
02 5
03 4
04 6
05 1
06 1
24100123 Jayne Doe
01 1
02 1
03 1
04 4
05 10
06 2
Missing Laura Taylor
I have tried with by using the -e argument with join like so:
join -a1 -e "Missing" results details > tempfile
But it seems to get ignored.
Thanks