任何人都可以解释以下代码:
for var in $1\*.html
echo $( basename -s .html $var )
done
-s
做什么?它是否从每个文件名中删除.html?
-s suffix
选项意味着basename
从文件名中删除后缀(如果存在)。
例如:
file=path/to/file.html
basename "$file" => yields file.html
basename -s .html "$file" => yields file
basename -s html "$file" => yields file.
basename -s .txt "$file" => yields file.html since the string has no .txt extension
不知道为什么你的for循环中有$1\*.html
- 这会抑制glob扩展,只会产生一个文字*.html
的文件。