【发布时间】:2010-01-24 12:07:39
【问题描述】:
我在一个文件夹中有数百个文件,名称如下:
index.html?tab=This is - the file name
我想删除 "index.html?tab=" 部分并为所有文件添加扩展名 ".txt"。如何使用 Unix 命令行工具(我使用的是 MacOSX 10.6.2)来做到这一点?
【问题讨论】:
标签: bash unix command-line
我在一个文件夹中有数百个文件,名称如下:
index.html?tab=This is - the file name
我想删除 "index.html?tab=" 部分并为所有文件添加扩展名 ".txt"。如何使用 Unix 命令行工具(我使用的是 MacOSX 10.6.2)来做到这一点?
【问题讨论】:
标签: bash unix command-line
在 bash 中,
for i in index.html\?tab\=*; do mv "$i" "${i:15}.txt"; done
【讨论】:
for file in index.html\?*
do
mv "$file" "${file#*=}".txt
done
【讨论】: