LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 07-28-2004, 05:53 PM   #1
Moto_Jon
LQ Newbie
 
Registered: May 2004
Location: California
Posts: 2

Rep: Reputation: 0
Creating switches in a bash script


Hello,

I am very new to writing scripts and am just trying to learn the basics. What I have done is created the following script:

filename=${1:?"filename missing."}
howmany=$2


echo ${album_line:9}
echo ${album_line:0:8}
echo -e -n ${header:+"ALBUMS ARTIST\n"}
sort -nr $1 | head -${howmany:=10}

and what I am trying to do is make it if you use -h, it will show the header when ran and if you don't use -h it will run normally. Also, I am trying to make it so I can use two other switches to just list one or the other column. I know it is probaly a stupid question but I am just trying to get my feet wet.

Thanks for the help,

Jon
 
Old 07-28-2004, 05:58 PM   #2
SheldonPlankton
Member
 
Registered: Jun 2004
Posts: 129

Rep: Reputation: 15
use getopt
reading ...
$ info getopt
... should get you started.
 
Old 07-28-2004, 06:06 PM   #3
Moto_Jon
LQ Newbie
 
Registered: May 2004
Location: California
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks for the quick reply, it helped.
 
  


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
problem creating BASH script with files that have whitespace scattaneo Linux - General 2 11-06-2004 05:40 PM
Bash script to do copying and ISO image creating, etc. satimis Programming 2 09-19-2004 09:47 PM
creating shell script that executes as root regardless of who runs the script? m3kgt Linux - General 13 06-04-2004 10:23 PM
Help creating a Bash script gothicreader Linux - Newbie 4 10-10-2003 01:36 PM
need help creating a bash script zibertron Linux - General 3 01-31-2003 09:23 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:20 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