- Create a new file called simple.3 which include these lines:
#!/bin/csh
if ($#argv == 0) echo There are no arguments
if ($#argv != 0) echo There are $#argv arguments
- After saving the file, make it executable and then run it as shown:
chmod +x simple.3
simple.3
- Now try running it several more times, but with a different number of
arguments each time. For example:
simple.3 one two
simple.3 a b c 3 4
simple.3 9*3 65 100.34 - will cause an error - why?
simple.3 '9*3' 65 100.34
simple.3 '10 disc write' - why is this considered 1?
- Edit the file again, adding the following lines:
if (-e $1) echo The file: $1 exists.
if (! -e $1) echo The file: $1 does not exist.
- Now execute the file with a filename as the only argument and observe
the output:
simple.3 nosuchfile
simple.3 simple.3
simple.3 simple
- Return to the tutorial to learn about the next section before proceeding.