作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试遍历目录中的每个文件。到目前为止,这是我的代码。
while read inputline
do
input="$inputline"
echo "you entered $input";
if [ -d "${input}" ]
then
echo "Good Job, it's a directory!"
for d in $input
do
echo "This is $d in directory."
done
exit
我的输出总是只有一行
this is $input directory.
为什么这段代码不起作用?我做错了什么?
很酷。当我回显时,它会打印出来
$input/file
为什么要这样做?它不应该只打印出没有目录前缀的文件吗?
最佳答案
for d in "$input"/*
关于linux遍历目录中的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1732861/
我是一名优秀的程序员,十分优秀!