I need to check if file exists in ccperl.
I tried to use 'if exists' but it didn't work.
I know sometimes we use " ' " in the beginning and the end of the command, but is there another way?
Thanks
What you probably want is -f 'myfile'
, which returns true if the name corresponds to a file.
There is a number of these tests , and you can use -e
to check that the name exists, but it could be either a file or a directory (or perhaps a link or a pipe on Unix).
Regarding ccperl (or ratpl) , check the version of the perl used (for old ClearCase versions, it is still a 5.8.6).
That can have an influence on using certain files tested with -f
, as this thread illustrates from a file with a trailing space .
You can see an example of ClearCase ccperl script here :
if ( $n_file != 0 ) {
while ( $file_name = shift(@file_list) )
{
if ( ! -f $vob_path.$dir_part.'/'.$file_name ) {
print "not found $vob_path".$dir_part.'/'."$file_name \n";
} else {
$size1 = &file_size($file_name);
$size2 = &file_size($vob_path.$dir_part.'/'.$file_name);
if ( $size1 != $size2 ) {
print "Err file $dir_part $file_name $size1 $size2\n";
}
}
}
}
(it would test also for directories, a few line below, with the -d
option)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.