发布网友
共2个回答
热心网友
[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
热心网友
for filename in `ls -F`
do
if [[ $filename =~ (.*\/$) ]] then
echo "$filename" >> /tmp/dir.txt
else
echo "$filename" >> /tmp/files.txt
fi
done
热心网友
[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
热心网友
for filename in `ls -F`
do
if [[ $filename =~ (.*\/$) ]] then
echo "$filename" >> /tmp/dir.txt
else
echo "$filename" >> /tmp/files.txt
fi
done