![]() |
|
|
|
|
|||||||
| 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 08:19 AM |
| How to check the file existence using shell scripting in Solaris-10 | krevathi1912 | SUN Solaris | 2 | 11-26-2007 02:07 AM |
| Variable check for existence ? | samit_9999 | UNIX for Dummies Questions & Answers | 2 | 12-05-2006 02: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 | Search this Thread | Display Modes |
|
#8
|
||||
|
||||
|
Hi.
Looking at the man page: Code:
#!/usr/bin/env csh # @(#) s1 Demonstrate file existence test in csh. echo echo "(Versions displayed with local utility version)" sh -c "version >/dev/null 2>&1" && version tcsh echo rm -f t1 t2 touch t1 t2 if ( -e t1 ) then echo " File t1 exists." else echo " File t1 does not exist." endif rm t2 if ( -e t2 ) then echo " File t2 exists." else echo " File t2 does not exist." endif exit 0 Code:
% ./s1 (Versions displayed with local utility version) tcsh 6.13.00 File t1 exists. File t2 does not exist. _____ Obligatory scripting advice: "use Bourne family, not csh family, for scripting". |
| Forum Sponsor | ||
|
|
|
#9
|
||||
|
||||
|
I'm not really sure why you piped ls into echo $status, but as indicated previous status is the same as $? in bourne based shells.
|
|
#10
|
|||
|
|||
|
Quote:
Hi Reborg, But what's your purpose of this statement " ls *_myfile >& /dev/null " before the statement " if ( $status == 0 ) then ". My code " ls *myfile|echo $status " was emulating this. I tried to perform "echo $status" in a directory with files and in a directory without files, the output is always " 0 ". So what does $status really mean ? |
|||
| Google The UNIX and Linux Forums |