[英]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.