我编写了以下脚本,用于从当前目录中查找 pdf 和 tex 文件的数量,包括子目录和隐藏文件。下面的代码能够找到最多 2 级子目录下面的 pdf 文件的数量,但之后它告诉没有子目录....
#!/bin/bash
touch t.txt
k=`find -type d |wc -l`
k1=`expr $k - 1`
echo $k1
message1="*.pdf *.tex"
count=`ls -al $message1|wc -l`
find -type d > t.txt
i=2
while [ $i -le $k ]
do
kd=`head -$i t.txt|tail -1`
echo $kd
touch $kd/t.txt
cp t.txt $kd/t.txt
i=`expr $i + 1`
done
i=2
while [ $i -le $k ]
do
nd=`head -$i t.txt|tail -1`
set -x
echo $nd
set +x
cd $nd
j=`ls -al …
Run Code Online (Sandbox Code Playgroud) 我编写了下面的脚本来查找给定目录中的 PDF 文件数。但是,它会显示目录中的所有文件:
#!bin/bash
message="."
message1="*.pdf"
ls -al $message $message1
Run Code Online (Sandbox Code Playgroud)
脚本有什么问题?