Chinaunix

标题: about upper case file name to low case , Thanks [打印本页]

作者: Unix1998    时间: 2004-01-19 22:26
标题: about upper case file name to low case , Thanks
Hi Dear Dxs,
Chinese input was damaged, sorry

a one line script , to change upper case files name to low case
files name, can't run correctly:
in current dir:
ls | xargs mv  $1 `echo $1| tr '[A-Z]' '[a-z]'`,

it is asked to use "xargs", do't use the below:
for i in "dir";
do mv $i  `echo $1| tr '[A-Z]' '[a-z]'`



Any help,

Thanks  a lot,
作者: john_student    时间: 2004-01-19 22:56
标题: about upper case file name to low case , Thanks
mymv.sh:
=============

mv $1 `echo $1 | tr '[A-Z]' '[a-z]'`

=============

cmd :
chmod 755 mymv.sh

ls | xargs ./mymv.sh
=============
作者: john_student    时间: 2004-01-19 23:03
标题: about upper case file name to low case , Thanks
sorry, it does not work .
作者: r2007    时间: 2004-01-19 23:36
标题: about upper case file name to low case , Thanks
这样如何?BTW:觉得楼主的例子不适合用xargs.
  1. ls -1|grep '[A-Z]'|xargs sh -c 'for i;do mv $i `echo $i|tr A-Z a-z`;done' null
复制代码

作者: john_student    时间: 2004-01-20 15:53
标题: about upper case file name to low case , Thanks
不用循环的话,只用xargs很难实现楼主的要求。




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2