Quote:
Originally posted by genderbender
Erm thanks, you wouldnt do my homework. Something along the lines of cat the customer file grep for number and output to a file and then grep vehicle for contents of that file would of been better and not doing my homework either!
|
I admit you have got half a point there.
Quote:
But manual pages which arent gonna help me all that much are pretty useless.
|
Probably true. Man pages generally are reference documents, which assume you already know how things work. For newbie's they can be pretty useless.
On the other hand, those web-links I posted, are step-by-step guides. Very readable. After working seriously through those, you know much more about bash than you need for this assignment. Similar doc's exist for e.g. awk.
Quote:
Problem is if i do what i just wrote ill get a file with about 8 lines all saying customer number 1 through to customer number 8. A direct problem would be how do i seperate each of these into single variables to search for in my vehicle file.
|
OK. I'll help you get going with that part (I feel a little bad. And helping with some perticular issue should OK)
customer.txt:
Code:
customer number 1
first name steve
surname johnson
post code wm83ee
telephone number 0800123456
customer number 2
first name heiko
surname noordhof
post code xc24df
telephone number 0503187138
customer number 3
first name ronald
surname reagan
post code xqqqqq
telephone number 004411223
cars.txt:
Code:
car reg no g428nug
colour green
model audi
year of manufacture 1991
selling price 200
sold flag Y
customer number 2
car reg no u477abc
colour blue
model toyota
year of manufacture 1992
selling price 230
sold flag Y
customer number 1
dbscript.sh
Code:
#!/bin/bash
grep 'customer number' customer.txt | while read CUST ; do
unset CARREG
cat cars.txt | while read LINE ; do
if echo "$LINE" | grep -q 'car reg' ; then
CARREG="$LINE"
fi
if echo "$LINE" | grep -q 'customer' ; then
if [ "$LINE" == "$CUST" ] ; then
echo "$CUST bought $CARREG"
fi
fi
done
done
Quote:
sorry if i sound rude, just feel a bit humiliated
|
I'm sorry about that.
It irritates me when people ask questions like "This is my homework", and then expect people here to help them cheat at school/college. If they don't want to learn programming, that's their choice. People here generally like to help other people
learn something, but doing their homework is the
opposite (then they learn nothing) and wasting my time. At least that's how I feel.
But when you got stuck, it's of course OK to ask here. But in that case there will be posted some code, or at least some
specific question. I feel people having a question, could at least takes some time actually ask some specific question. Just: "This is my homewerk, PLEASE HELP!!!" doesn't cut it.
I guess, your question was somewhere in the middle. And I may have been a little harsh on you in my first reply.