Как вы упомянули, это, скорее всего, связано с конфигурацией SELinux. Как предложено в этом ответе, выполните следующую команду, чтобы решить проблему:
chcon -R -t httpd_sys_content_t /var/ftc/
# ls -Zd /var/www/html/ /var/ftc/
unconfined_u:object_r:var_t:s0 /var/ftc/
unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html/
# chcon -R -t httpd_sys_content_t /var/ftc/
# ls -Zd /var/www/html/ /var/ftc/
unconfined_u:object_r:httpd_sys_content_t:s0 /var/ftc/
unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html/
Как насчет:
#!/bin/bash
# The first command line parameter is the size limit
LIMIT="$1"
shift 1
# Now loop over the rest of the command line parameters, which are the file names to check.
for file in "$@"; do
SIZE="$(stat --format="%s" "$file")"
if [ "$SIZE" -gt "$LIMIT" ]; then
echo "$file is $SIZE bytes. Deleting..."
rm "$file"
fi
done
Ограничение размера будет указано в качестве первого параметра, а все имена файлов будут указаны после него.
Например, с ограничением размера в 400 байт:
script.sh 400 file1 file2 file3... fileN
Вы также можете использовать подстановочные знаки:
script.sh 600 *.txt file1 bigfile2*.log dir1/*.txt dir2/*.old