Некоторые другие идеи.
top -d10 -n2 >/dev/null
vmstat 10 2 >/dev/null
sar 10 1 >/dev/null
timeout 10s tail -f /dev/null
Вы пропустили -z
и $
в -z "$file2"
. Кроме того, вам не нужно заключать имена файлов в кавычки (, это не вызывает ошибки, хотя ). Запустите приведенные ниже тесты, используя в качестве примера лайнер Perl one -:
rm -rf foo bar
touch foo
perl -le 'my $file1 = "foo"; my $file2 = "bar"; if ( -z $file1 && -z $file2 ) { print "file1 and file2 are empty"; } else { print "execute"; }'
# File 'bar' does not exist, so -z $file2 evaluates to false:
# execute
rm -rf foo bar
touch foo bar
perl -le 'my $file1 = "foo"; my $file2 = "bar"; if ( -z $file1 && -z $file2 ) { print "file1 and file2 are empty"; } else { print "execute"; }'
# Both files exist and are zero size, so both '-z' tests evaluate to true:
# file1 and file2 are empty
rm -rf foo bar
touch foo bar
echo '1' > bar
perl -le 'my $file1 = "foo"; my $file2 = "bar"; if ( -z $file1 && -z $file2 ) { print "file1 and file2 are empty"; } else { print "execute"; }'
# File 'bar' iz non-zero size, so -z $file2 evaluates to false:
# execute
Вы пропустили -z
в выражении if
.
if ( -z "$file1" && -z "$file2" ) {
print "file1 and file2 are empty";
}
else {
print "execute";
}