Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想找到一个 bash 脚本,用于将带有 _(下划线)的文件重命名为 -(连字符)
例如将文件名 my_page_name.php 更改为 my-page-name.php,保持没有 .php 扩展名的文件名相同
我尝试过:Nothing yet ,只是使用此处找到的脚本 bbs.archlinux.org/viewtopic.php?id=36305 并将空格替换为 _ 并将下划线替换为 -
If you only need to do it in one directory (and not subdirectories):
for f in *_*; do mv "$f" "${f//_/-}"; done
Otherwise, you can use find to -exec a bash subshell.
find
-exec
使用rename程序:
rename
rename s:_:-: *.php