Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 01-30-2005, 02:21 PM   #1
Registered: Jan 2005
Location: US
Distribution: Centos, Ubuntu, Solaris, Redhat
Posts: 396

Rep: Reputation: 31
Multiple searches (sorry if this is a long thread)

This is part of my assignment and two of the assignment "problems" are I cant use switches and its gotta be bash (not a problem really). Its my first bash program so you'll have to go easy as this is probably quite a basic question.

Ive got two database files called vehicle and customer. Heres an example of one customer in the customer file, there are others in it obviously.

customer number 3
first name steve
surname johnson
post code wm83ee
telephone number 0800123456

my vehicle database look like this:

car reg no g428nug
colour green
model audi
year of manufacture 1991
selling price 200
sold flag Y
customer number 3

I've done nearly all the script apart from this section and i dont really know where to start besides grep, but i need multiple instances of grep to search and output lots of different things and then compare them with the other file. Heres the bit I'm stuck on:

"Perform an audit (i.e. consistency check) of the database. You will identify all customer records with no corresponding vehicle record and all vehicle records marked as sold with no corresponding customer record."

I think my good old cisco lecturer who hates programming would also be impressed with an output like echo "records are consistant" or records are crap, whatever. Only way i can think of doing this is a switch but its not allowed

Any help at all, even a clue as to how I'd do this would be perfect.

Thanks a LOT!
Old 01-30-2005, 04:41 PM   #2
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
customers with no vehicle: make a big grep on customer number in vehicle database and compare with the same grep (sorted, probably) on customers. To compare them you can use diff (if you're allowed to use it).

sold vehicles with no customer: if the database looks always the same and customer number should be always after sold flag try to use and of line mark with grep regexp.
Old 01-30-2005, 06:03 PM   #3
Registered: Jan 2005
Location: US
Distribution: Centos, Ubuntu, Solaris, Redhat
Posts: 396

Original Poster
Rep: Reputation: 31
Thanks a lot mate, thats precisely what i was after. I accidently posted this twice and got in a lot of trouble (not only for posting twice but asking for help).

Thanks a lot, I'll do that tomorrow and thanks not for sending me to man bash etc....


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Hardware issues (long post) Rahven Linux - Hardware 8 02-11-2007 05:20 AM
What one should do if there's no answers to his thread/post for a long time ? kuser:) LQ Suggestions & Feedback 10 09-27-2005 05:03 PM
Multiple searches? genderbender Programming 7 01-30-2005 04:20 PM
Searches Thulemanden LQ Suggestions & Feedback 1 12-05-2004 10:26 AM
Any good thread programming theory (for multiple cpus) book/tutorial karlan Programming 3 10-04-2004 11:48 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:11 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration