寻觅生命中的那一片浅草......

每日存档 九月 24th, 2010

关于Shell的补零,用printf来格式化数字列。

解答论坛一个朋友关于获取01、02…10,而非1、2….10。
因为需要用flashget下载这样一些列的文件。自己了解这个应用,但是以前也没有处理过。还是有需要的。经过g后,测试得到。

[root@kook tmp]# cat for.sh
for ((a=1; a<=10 ; a++))
do
printf “%02d\n” $a
done
[root@kook tmp]# ./for.sh
01
02
03
04
05
06
07
08
09
10

这么写,也可以。

[root@kook tmp]# cat for.sh
for ((a=1; a<=10 ; a++))
do
printf “%.2d\n” $a
done

继续测试。

[root@kook tmp]# printf “%04d\n” -3
-003
[root@kook tmp]# printf “%.4d\n” -3
-0003

转载自:http://cnc.52zhe.cn/read.php/165.htm

Linux下删除特殊名字的文件

http://www.52zhe.cn/r以前曾写过删除以”-“开头的文件,链接在这里http://www.52zhe.cn/read.php/153.htm,最近又碰到乱码的文件,这次用i节点来删除,无论什么文件都可以用这种方式删除,当然也包括文件夹。

先用ls -i *获取那个文件的i节点,然后用find命令加管道删除即可。假设那个文件i节点为25000,进入那个文件所在目录下面,如下操作:

方法1:
find ./ -inum 25000 | xargs rm -rf
方法2:
find ./ -inum 25000 -exec rm {} -rf \;

转载自:http://cnc.52zhe.cn/read.php/223.htm

2010年九月
« 8月   10月 »
 12345
6789101112
13141516171819
20212223242526
27282930