#!/bin/csh

Syntax

Output to dev/null:

portsnap extract >& /dev/null
File Operators
  • -e file exists
  • -o file exists and is owned by the user
  • -r file exists and is readable
  • -w file exists and is writable
  • -x file exists and is executable
  • -z file exists and is zero size
  • -d dir exists and is a directory

Examples

Loops

The syntax is different here, in that there is no in keyword.

#!/bin/csh
foreach x ( one two three )
  echo number $x!
end
If .. Then
#!/bin/csh
foreach filename ( foo.tar.gz bar.tar.bz2 )
  if ( ! -e $filename ) then
    echo "I can't find $filename anywhere!"
  endif
end
Passing Arguments
#!/bin/csh
echo found $#argv arguments
echo first argument is: $argv[1]
echo second argument is: $argv[2]
args.csh Hello CSH