linux - 如何将文件名改为小写?

标签 linux bash shell

我需要使用 bash 脚本将特定目录中所有文件的所有名称更改为小写。此外,我不想更改子目录的名称,正如 How to rename all folders and files to lowercase on Linux? 中提出的那样。

最佳答案

for file in *; do
    [[ -f "$file" ]] && mv "$file" "${file,,}" 2>/dev/null
done

我不确定哪个版本的 bash 引入了 ${var,,} 扩展。

关于linux - 如何将文件名改为小写?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21119382/

相关文章:

ruby - 如何确定 XFS 文件系统是否以编程方式卡住?

c - 为什么从服务器响应中读取的实际字节数小于 Content-Length?

linux - 如何在 bash 脚本中递归地执行 foreach *.mp3 文件?

bash - ROS 安装 : no such file or directory

linux - 自动应答 bash 脚本提示

linux - Shell 脚本(使用 top 命令)在 cronjob 中不起作用

python - 与 django cms 中的 views.py 文件相关的查询

linux - 从文件中提取数字

linux - 终端命令的结果作为 C++ 文件的命令行参数

c - 在 C 中实现 shell 并需要帮助处理输入/输出重定向