The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #7 (permalink)  
Old 12-05-2007
denn denn is offline
Registered User
 

Join Date: Jul 2007
Posts: 93
$status in csh/tcsh is the same as $? in sh/ksh

The below should work for you, for multiple files.

Code:
#!/bin/csh

foreach file ( $* )
ls $file 2>&1 /dev/null
        if ( $status == 0 ) then
                echo $file
        else
            echo "no files"
        endif
end
to test: ./scriptname file1 file2 file3
Reply With Quote