简体   繁体   English

如何使用终端大写当前目录中的所有文件?

[英]How to capitalize all files in the current directory using terminal?

I am trying to capitalize all files in my current working directory using the following command: 我正在尝试使用以下命令将当前工作目录中的所有文件大写:

ls | awk '{system("svn mv " $0 " " toupper(substr($0,1,1)) substr($0,2))}'

Yet, I am getting the following error message: 但是,我收到以下错误消息:

svn: '.' is not a working copy
svn: '.' is not a working copy
svn: '.' is not a working copy
svn: '.' is not a working copy

I am on a osx. 我在OSX上。 Could you please help? 能否请你帮忙? Thanks in advance. 提前致谢。

you should not use ls in scripting, ls is for human presentation of data (and will surprise your scripts with space in names, special folders like . and .. like here and so on...), try instead: 您不应该在脚本中使用ls,而是用于人为表示数据(ls会使脚本中的名称,特殊文件夹(如。和..,如此处,依此类推等等)带有空格),请尝试:

for f in *;do;svn mv $f $(echo $f| tr '[a-z]' '[A-Z]');done

See here for other case conversions alternatives , I used tr since awk is not needed here. 有关其他大小写转换的替代方法请参见此处 ,我使用了tr,因为这里不需要awk。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Bash 将目录中的所有文件大写 - Capitalize all files in a directory using Bash OSX Terminal命令将所有文件移动到目录中 - OSX Terminal command to move all files in directory 如何在Mac终端中列出给定目录的所有文件,但文件或目录除外 - How to list all files of a given directory in Mac terminal except a file or directory 命令使用Unix Terminal打开当前文件夹中具有指定扩展名的所有文件吗? - Command to open all files with a specified extension the current folder using Unix Terminal? Mac 终端自动完成提示文件不在当前目录中 - Mac terminal auto-complete is suggesting files not in current directory OSX终端脚本-尝试打开目录中的所有文件 - OSX terminal script - Try to open all files in directory 如何让 ZSH 在终端框架中显示当前目录? - How do I get ZSH to display the current directory in the Terminal frame? 在Mac终端中,我想在当前目录中找到某些文件,但是输出不是我想要的? - In the Mac terminal, I want to find certain files in current directory, but the output is not what I want? 如何修改我的 zsh 终端提示符以显示当前工作目录和当前 git 分支(如果适用)? - How can I modify my zsh terminal prompt to show the current working directory and current git branch (if applicable)? Swift 3 读取终端当前工作目录 - Swift 3 Read Terminal Current Working Directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM