Difference between revisions of "Positional parameters set"
From assela Pathirana
Jump to navigationJump to search
Line 1: | Line 1: | ||
{{Template:needs-cygwin-or-linux}} | |||
Following is an example of positional parameters created by command line arguments being later replaced by others. | Following is an example of positional parameters created by command line arguments being later replaced by others. | ||
<pre> | <pre> |
Latest revision as of 12:59, 6 April 2006
The commands on this page can be tried out on Cygwin installed in a windows PC or on any UNIX computer.
Following is an example of positional parameters created by command line arguments being later replaced by others.
#!/bin/bash #try calling this with several arguments echo '$1=' $1 echo '$2=' $2 echo '$3=' $3 set `ls` echo '$1=' $1 echo '$2=' $2 echo '$3=' $3
The first echo statements will print the command line arguments; but the second set will print the first three files in the current directory! The set command replace the positional parameters with the output of ls command.