#!/bin/bash
# get all filename in specified path
n=0
#path=$1
#files=$(ls -p | grep -v /)
files=`find -maxdepth 1 -name "*.cae"`
for filename in $files
do
filename=${filename:2} #delete the first two characters "./"
echo ${filename%.*}
let n++
num=$(expr $n % 2)
#echo $num
if [ $num == 0 ]
then
echo $n
fi
done
Bash获得当前文件夹之下后缀一样的所有的文件名
这篇文章介绍了如何编写一个bashshell脚本,用于在指定路径下查找所有名字以.cae结尾的文件,删除路径前缀,并按每行输出奇数编号的文件名。

1996

被折叠的 条评论
为什么被折叠?



