[Ilugc] Shell script with arguments

Balachandran Sivakumar benignbala at gmail.com
Tue Jul 17 18:13:41 IST 2012


On Tue, Jul 17, 2012 at 5:57 PM, Vijay Kumar <vijayakumarnkdr at gmail.com> wrote:
> Hi All,
> I need some help/ideas in coming up with a shell script.
> For example, if I type in pkgscript.sh a1 a2 a3, it should install all the
> 3 scripts and pkgscript.sh a1 should install only a1.

Use $# and $@. A rough outline is :

if  [[ $# == 0 ]]; then
    <do something>

for pkg in "$@"
         <install ${pkg}>

Please read up on bash programming. This will be covered there. thanks

Thank you
Balachandran Sivakumar

Arise Awake and stop not till the goal is reached.
                                                             - Swami Vivekananda

Mail: benignbala at gmail.com
Blog: http://benignbala.wordpress.com/

More information about the ilugc mailing list