![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Check existence of a login | xavier054 | UNIX for Advanced & Expert Users | 10 | 03-06-2008 07:19 AM |
| How to check the file existence using shell scripting in Solaris-10 | krevathi1912 | SUN Solaris | 2 | 11-26-2007 01:07 AM |
| Variable check for existence ? | samit_9999 | UNIX for Dummies Questions & Answers | 2 | 12-05-2006 01:15 PM |
| check for FILES existence | mpang_ | Shell Programming and Scripting | 3 | 06-28-2006 03:51 AM |
| File existence | mpang_ | Shell Programming and Scripting | 2 | 03-27-2006 08:27 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Csh to check for existence of file
Hi,
I would like to check the existence of files (doesn;t matter the number of files) in a directory. My file is named in the following manner (always ending with " myfile "). Can anybody give me some guidance? EG: abc1_myfile sdfr_myfile sffgd_myfile and so on ...... My intention is to perform the following: if file exist, perform plan A. else perform plan B. |
| Forum Sponsor | ||
|
|
|
|||
|
hi reborg,
I tried the " $status " in a directory containing *myfile. And these statement appear " Reset tty pgrp from 7873 to 11434 ". What does this statement mean ? Is " $status " a special variable in csh ? Code:
% ls *myfile xxx1_myfile xxx2_myfile % ls *myfile|echo $status 0 % Reset tty pgrp from 7873 to 11434 |
|
|||
|
$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
|
|||
| Google The UNIX and Linux Forums |