Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 08-07-2003, 06:47 AM   #1
LQ Guru
Registered: Apr 2003
Location: nottingham england
Distribution: Gentoo
Posts: 2,672

Rep: Reputation: 47
pass parameters to shell scripts ?

Hi guys.

how do i pass a parameter to a shell script, in a way that the shell script will then pass that parameter to an executable ???

Old 08-07-2003, 07:23 AM   #2
Registered: Sep 2002
Location: IN, USA
Distribution: Debian, Endian FW
Posts: 368

Rep: Reputation: 30
With bash you can access them with $n. Where 0 is the script itself and 1, on are the arguments passed
Old 08-07-2003, 07:27 AM   #3
Registered: Aug 2003
Location: /dev/null
Posts: 40

Rep: Reputation: 15
suppose you have the shell script


echo "you passed the parameter $1";

now execute the file

./ hello

this will print you passed the parameter hello

to pass it to other programs:


echo "parameter $1"

/usr/bin/find $1

now, when you execute

$./ \/etc\/
it will print parameter /etc/
and then execute 'find' with the parameter /etc/ (will display all the files in /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
shell: positional parameters... neidias Programming 1 04-04-2005 02:45 PM
How to pass on boot parameters Slack 10.1 tdking19 Slackware 3 03-21-2005 10:41 AM
Pass Parameters to php from bash iman00b Linux - Newbie 2 09-09-2004 05:30 PM
how do I pass special parameters to the kernel at startup? Falafel Fedora 4 01-19-2004 06:49 PM
howto pass parameters to modules Sammy2ooo Linux - Software 5 07-01-2003 08:30 PM > Forums > Linux Forums > Linux - Newbie

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

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