Register
It is currently Thu Dec 18, 2014 5:19 pm

Parse parameters with getopts


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Mon Mar 29, 2010 4:54 am   

Joined: Mon Mar 29, 2010 4:53 am
Posts: 1
Hi, this is my problem

I have script with two parameters -n name and -s surname. Both have arguments and I want to know how parse these parameters with getopts. When you write

./names -n John -s White
it find you all persons, which name is John White, but when you write

./names -n John
it will find you all Johns in database. Similar when you write

./names -s White
it will find all person who have White in their surname.

What is more ./names -n John -s White must be equal to ./names -s White -n John

EDIT: Oh and I almost forgot

every person is in unique file, where is name on first line and surname on second line

Is it possible?


Top
 Profile  
 PostPosted: Mon Mar 29, 2010 7:50 am   

Joined: Tue Mar 02, 2010 9:55 pm
Posts: 24
Location: Canada
Here's a good link that explains and show a few examples of getopts

http://www.bash-hackers.org/wiki/doku.p ... s_tutorial


Top
 Profile  
 PostPosted: Tue Mar 30, 2010 3:06 am   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 579
this is a nice TODO.

thank you frees:
students would be delighted. or not :(
:D


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP