#!/bin/bash
for file in *
do
if [ -s $file ]; then
continue
else
echo "$file is empty and will be removed"
rm $file
fi
done
for file in *
do
if [ -x $file -a -f $file ];then
echo "$file is an executable"
fi
done
是否有更简单的方法来编写此脚本,以便将其全部用于1 for for循环?
答案 0 :(得分:1)
试试这个:
#!/bin/bash
for file in *; do
if [ -s "$file" ]; then
if [ -x "$file" -a -f "$file" ]; then
echo "$file" "is an executable"
fi
else
echo "$file" "is empty and will be removed"
rm "$file"
fi
done