LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-02-2006, 08:26 AM   #1
basak
Member
 
Registered: Jul 2006
Posts: 41

Rep: Reputation: 15
while writing your own Bash shell command


Hi;
I have to write a couple of user defined Bash shell commands but I do not know how I will make these commands have some options(like -o,-l etc.) or have some input or output files as arguments.Thanks..
 
Old 08-02-2006, 09:23 AM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Are you writing them as shell scripts? Or functions? In either case, all arguments are available in $*, you just need to parse them. Or, if you're concerned with position, you could use $1..$n for "n" arguments.

Last edited by Matir; 08-02-2006 at 09:25 AM.
 
Old 08-02-2006, 09:37 AM   #3
basak
Member
 
Registered: Jul 2006
Posts: 41

Original Poster
Rep: Reputation: 15
I 'm supposed to write them as shell scripts but from the tutorials I have read so far ,I could not learn how a command recognizes a given valid(or gives an error if it is unvalid) option or uses a given file as an argument.
 
Old 08-02-2006, 10:13 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Checked your tuts for "getopts"?
 
Old 08-02-2006, 10:58 AM   #5
johnson_steve
Senior Member
 
Registered: Apr 2005
Location: BrewCity, USA (Milwaukee, WI)
Distribution: Xubuntu 9.10, Gentoo 2.6.27 (AMD64), Darwin 9.0.0 (arm)
Posts: 1,152

Rep: Reputation: 46
Check out the Advanced bash scripting guide:

http://www.tldp.org/LDP/abs/html/
 
  


Reply



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
goto/label command for scripting in bash shell terry.trent Linux - Software 3 07-09-2010 10:15 AM
about the bash shell command naihe2010 Programming 7 10-27-2005 12:40 AM
bash shell command line expansion hansi umayangan Linux - General 2 03-13-2005 11:31 AM
Bash shell command on windows98 emailssent General 3 10-16-2004 06:25 AM
Specifying target directory for command in bash shell script? spectrescape Programming 1 07-22-2004 05:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:18 PM.

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