Linux bash脚本

发布网友 发布时间: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

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com