Skip to content Accesskey=4Skip to sub-navigation Accesskey=3View our Accessibility Options MIT Information Systems Home About IS&T Contact IS&T Site Map Search Advanced Search
Getting StartedGetting Services by Topic or Alphabetically Getting Help

On This Page

[Help]

  

Quick Links

Top Level

Related Links

Ask OLC a question

Athena Consulting Homepage

Helpdesk Stock Answers (for Mac/PC questions)


Using shell script PARAMETERS

Parameters from the command line can be used within a C-shell script by using
the pseudo-variables '$0', '$1', '$2', etc.

For example, if you have a script named 'foo', and you want to give it two
parameters, 'bar1' and 'bar2'.  You would type this command:

	foo bar1 bar2

Within the script, '$1' will return the first parameter 'bar1', and '$2' will
return the second parameter 'bar2'.  '$0' returns the command name, 'foo'.
So, if the script foo contained these lines:

	#!/bin/csh -f
	echo 'Command:' $0
	echo 'Parameters:' $1 $2

...then the above command would produce the following output:

	Command: foo
	Parameters: bar1 bar2

To learn more about shell programming, you can read the manual page for 'csh'
by using the 'man' command:

	man csh

MIT Home | Getting Started | Getting Services | Getting Help | About IS&T | Accessibility
Ask a technology question or send a comment about this web page.