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

关于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

自动kill掉超时的mysql show processlist进程

DB_HOST=”localhost”
DB_PORT=3306
DB_USER=”root”
DB_PASS=””
maxtime=10
sql=”SHOW PROCESSLIST”
sss=$(/usr/bin/mysqladmin processlist|sed -e “s/\s//g”|awk -F’|’ ‘{print $2,$7,substr($9,1,6)}’|awk ‘{if($2>'”$maxtime”‘ && $3==”SELECT”){print $1}}’)
for pid in $(echo “$sss”); do
/usr/bin/mysql -h$DB_HOST -P$DB_PORT -u$DB_USER -p$DB_PASS -e “kill $pid”
done
echo “$sss”
date

转载自:http://home.phpchina.com/space.php?uid=24549&do=blog&id=158758

The CentOS CD was not found in any of your CDROM drives

These days I customize CentOS5.4,I boot my ISO on vm , after I select languages and keyboard type, I meet this error:
The CentOS CD was not found in any of your CDROM drives.Please insert the CentOS CD and press OK to retry.

I compare the files of the offical ISO and my ISO, I find a file named “.discinfo” is not present in my ISO.Copy it to my ISO and the problem is solved.

Now I know “cp -a” will not handle the hidden file.

MySQL报错:my_global.h151615 error new No such file or directory

今天安装MySQL,在make的时候报错,错误信息如下:

In file included from mysys_priv.h:16,
from my_new.cc:21:
../include/my_global.h:1516:15: error: new: No such file or directory
make[1]: *** [my_new.o] Error 1
make[1]: Leaving directory `/opt/mysql-5.1.45-10/mysys’
make: *** [all-recursive] Error 1

检查了操作系统版本等情况,都没问题,configure时也没报错,可以正常产生Makefile

将有问题服(假设是A机)的config.log和另外一台正常服(假设是B机)的config.log做对比

发现A机,有2处比较严重的报错

conftest.c:181:21: error: termcap.h: No such file or directory
conftest.cpp:314:20: error: cxxabi.h: No such file or directory

在B机上
updatedb

for i in `locate termcap.h`; do rpm -qf $i; done |uniq
输出:
libtermcap-devel-2.0.8-46.1
ncurses-devel-5.5-24.20060715
dev86-0.16.17-2.2

for i in `locate cxxabi.h`; do rpm -qf $i; done |uniq
输出:

libstdc++-devel-4.1.2-48.el5
libstdc++44-devel-4.4.0-6.el5
xulrunner-devel-1.9.0.18-1.el5_4

到A机上用rpm -qa查询libtermcap-devel,ncurses-devel,dev86,libstdc++-devel,libstdc++44,xulrunner-devel的安装情况
发现libtermcap-devel,dev86,libstdc++-devel没有安装

yum -y install libtermcap-devel dev86 libstdc++-devel

然后再make,就没有报错了

2025年七月
« 5月    
 123456
78910111213
14151617181920
21222324252627
28293031