#!/bin/bash
echo "" >> "regular file"
echo "" >> "Directory file"
echo "" >> "executable file"
target="/home/personal/scripts/07_22_13/ford/$1"
for f in "$target"/*
do
echo $(basename $f) | ls -la
if [[ -x "$f" ]];
then
echo "File '$f' is executable"
elif [[ -r "$f" ]];
then
echo "file '$f' is regular"
else echo "file '$f' is directory"
echo "*(-^/)"
fi
done
代码打印具有访问权限的所有文件 我如何打印每个类型(常规,目录,可执行文件)
的文件旁边答案 0 :(得分:0)
if [[ -x "$file" ]]; # File is executable
if [[ -d "$file" ]]; # Is a directory
答案 1 :(得分:0)
试试这种方式
#!/bin/bash
target="/path/to/target/"
for file in `find ${target}`
do
stat --format=%n\ -\ %F\ -\ %A $file
# %n prints the filename
# %F prints the filetype
# %A prints the permissions
#For more info stat --help or man stat
done