Chinaunix首页 | 论坛 | 博客
  • 博客访问: 57953
  • 博文数量: 17
  • 博客积分: 720
  • 博客等级: 军士长
  • 技术积分: 155
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-21 13:34
文章分类

全部博文(17)

文章存档

2011年(1)

2009年(1)

2008年(5)

2007年(6)

2006年(4)

我的朋友
最近访客

分类:

2006-03-30 13:40:20

  只要一条命令就可以将目录下的所有文件名改为大写,如下:
  [root@localhost tmp]$for file in $(ls ./); do mv $file $(echo $file|tr "[a-z]" "[A-Z]"); done
 
  如果要将文件名中第X位改为大写,并且可以处理子目录中的文件,则参考如下:
 
find . -name "*.htm"|while read file;do
     echo "mv $file $(echo $file|rev|awk '{print substr($0,1,4)toupper(substr($0,5,1))substr($0,6,length($0))}'|rev)"|sh
done

  从这个问题中,发现了自己的基础知识还有待提高。居然不知道tr命令。

  感谢CU论坛高人:零二年的夏天,寂寞烈火

阅读(1500) | 评论(1) | 转发(0) |
0

上一篇:没有了

下一篇:linux进程管理

给主人留下些什么吧!~~

chinaunix网友2011-05-12 23:14:39

A more simpler way to do this: find . -name "*.htm"|while read file;do echo "mv $file $(echo $file|awk '{print substr($0,1,'"$(($n-1))"')toupper(substr($0,'"$n"',1))substr($0,'"$(($n+1))"',length($0))}')"|sh done