发布网友 发布时间:2022-04-23 12:56
共2个回答
热心网友 时间:2023-10-14 10:28
[root@wy ~]# cat test172.sh
#! /bin/bash
read -p "Enter a path:" Path
for way in `ls $Path`
do
if [ -d "$way" ]
then echo "$way" >> /tmp/dir.txt
elif [ -f "$way" ]
then echo "$way" >> /tmp/files.txt
fi
done
热心网友 时间:2023-10-14 10:28
for filename in `ls -F`
do
if [[ $filename =~ (.*\/$) ]] then
echo "$filename" >> /tmp/dir.txt
else
echo "$filename" >> /tmp/files.txt
fi
done
热心网友 时间:2023-10-14 10:28
[root@wy ~]# cat test172.sh
#! /bin/bash
read -p "Enter a path:" Path
for way in `ls $Path`
do
if [ -d "$way" ]
then echo "$way" >> /tmp/dir.txt
elif [ -f "$way" ]
then echo "$way" >> /tmp/files.txt
fi
done
热心网友 时间:2023-10-14 10:28
for filename in `ls -F`
do
if [[ $filename =~ (.*\/$) ]] then
echo "$filename" >> /tmp/dir.txt
else
echo "$filename" >> /tmp/files.txt
fi
done