![“.gz”扩展名以某种方式附加到我的网站上的每个文件...我该如何撤消它?](https://linux22.com/image/1365700/%E2%80%9C.gz%E2%80%9D%E6%89%A9%E5%B1%95%E5%90%8D%E4%BB%A5%E6%9F%90%E7%A7%8D%E6%96%B9%E5%BC%8F%E9%99%84%E5%8A%A0%E5%88%B0%E6%88%91%E7%9A%84%E7%BD%91%E7%AB%99%E4%B8%8A%E7%9A%84%E6%AF%8F%E4%B8%AA%E6%96%87%E4%BB%B6...%E6%88%91%E8%AF%A5%E5%A6%82%E4%BD%95%E6%92%A4%E6%B6%88%E5%AE%83%EF%BC%9F.png)
不知怎的,我意外地将扩展名附加.gz
到了我的整个网站目录中的所有文件中。
我该如何撤消此操作?我需要它们保留其原始文件扩展名(例如:picture.jpg.gz
-> picture.jpg
| file.php.gz
-> file.php
)。
答案1
如果它们确实被压缩了:
find -name "*.gz" -exec gunzip {} \;
答案2
尝试使用mv
命令:
for f in *.gz; do
mv "$f" "$(basename "$f" .gz)"
done
basename
返回路径的副本。
答案3
要使用正则表达式编辑大量文件,请尝试使用维迪尔:
When editing a directory, each item in the directory will appear on its
own numbered line. Delete lines to remove files from the directory, or edit
filenames to rename files. You can also switch pairs of numbers to swap
filenames.
答案4
这可能会有帮助:
rename ".gz" "" <filename>