<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>我的备忘录 &#187; bash</title>
	<atom:link href="http://www.nimab.org/tags/bash/feed" rel="self" type="application/rss+xml" />
	<link>http://www.nimab.org</link>
	<description>穷困潦倒</description>
	<lastBuildDate>Mon, 29 Aug 2011 02:53:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>几行bash分析日志并报警强力蜘蛛</title>
		<link>http://www.nimab.org/2008/08/25/51.html</link>
		<comments>http://www.nimab.org/2008/08/25/51.html#comments</comments>
		<pubDate>Mon, 25 Aug 2008 10:45:57 +0000</pubDate>
		<dc:creator>xdanger</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[log]]></category>

		<guid isPermaLink="false">http://www.nimab.org/?p=51</guid>
		<description><![CDATA[被SB蜘蛛抓烦了，今天早上一看，有2个IP一小时就抓了我80G的页面，还都是动态页面。 首先让 Apache 记的日志最小化，好处不用说了。 SetEnvIfNoCase Request_URI \.gif$ dontlog SetEnvIfNoCase Request_URI \.jpg$ dontlog SetEnvIfNoCase Request_URI \.png$ dontlog SetEnvIfNoCase Request_URI \.swf$ dontlog SetEnvIfNoCase Request_URI \.css$ dontlog SetEnvIfNoCase Request_URI \.js$ dontlog SetEnvIfNoCase Request_URI \.ico$ dontlog CustomLog "&#124;/usr/local/sbin/cronolog /var/log/httpd/%Y-%m/%d-%H.ip" "%{X-Forwarded-For}i" env=!dontlog 因为我的 Apache 是躲在 n 层代理的后面，所以只能记录 %{X-Forwarded-For}，里面包含真实 IP，但是需要下一步分析去取出。 cd /var/log/httpd f=`date -d '1 hours ago' +%Y-%m/%d-%H.ip` ip=`sed 's#^\([0-9\.]\{1,\}\)[0-9 \.,\s]\{1,\}#\1#' [...]]]></description>
			<content:encoded><![CDATA[<p>被SB蜘蛛抓烦了，今天早上一看，有2个IP一小时就抓了我80G的页面，还都是动态页面。</p>
<p>首先让 Apache 记的日志最小化，好处不用说了。</p>
<p><code><br />
    SetEnvIfNoCase Request_URI \.gif$ dontlog<br />
    SetEnvIfNoCase Request_URI \.jpg$ dontlog<br />
    SetEnvIfNoCase Request_URI \.png$ dontlog<br />
    SetEnvIfNoCase Request_URI \.swf$ dontlog<br />
    SetEnvIfNoCase Request_URI \.css$ dontlog<br />
    SetEnvIfNoCase Request_URI \.js$  dontlog<br />
    SetEnvIfNoCase Request_URI \.ico$ dontlog<br />
    CustomLog "|/usr/local/sbin/cronolog /var/log/httpd/%Y-%m/%d-%H.ip" "%{X-Forwarded-For}i" env=!dontlog<br />
</code></p>
<p>因为我的 Apache 是躲在 n 层代理的后面，所以只能记录 %{X-Forwarded-For}，里面包含真实 IP，但是需要下一步分析去取出。</p>
<p><code><br />
cd /var/log/httpd<br />
f=`date -d '1 hours ago' +%Y-%m/%d-%H.ip`<br />
ip=`sed 's#^\([0-9\.]\{1,\}\)[0-9 \.,\s]\{1,\}#\1#' $f | awk '{a[$1]++ } END{for(i in a){print a[i] " " i}}' | sort -rn | head`<br />
curl -u 机器人的饭否登录名:密码 -d status="$ip" http://api.fanfou.com/statuses/update.xml<br />
rm $f<br />
</code></p>
<p>测试下来一小时 10M 的 log，分析一下也就 3 秒左右，还有1秒是发送给饭否的报警的。如果记录的直接就是真实 IP，那可以去掉 sed 那段，分析应该还会快很多（log文件就小很多了）。</p>
<p>看到有夸张的，不是常规搜索引擎蜘蛛的话，就咔嚓掉。<br />
<code><br />
iptables -A INPUT -s xxx.xxx.xxx.xxx/29 -j DROP<br />
</code><br />
1          202.106.186.*        163蜘蛛<br />
2          202.108.36.*        163蜘蛛<br />
3          202.108.44.*        163蜘蛛<br />
4          202.108.45.*        163蜘蛛<br />
5          202.108.5.*        163蜘蛛<br />
6          202.108.9.*        163蜘蛛<br />
7          220.181.12.*        163蜘蛛<br />
8          220.181.13.*        163蜘蛛<br />
9          220.181.14.*        163蜘蛛<br />
10        220.181.15.*        163蜘蛛<br />
11        220.181.28.*        163蜘蛛<br />
12        220.181.31.*        163蜘蛛<br />
13        222.185.245.*        163蜘蛛<br />
14        202.165.100.*        3721蜘蛛<br />
15        220.181.19.*        百度蜘蛛<br />
16        159.226.50.*        百度蜘蛛<br />
17        202.108.11.*        百度蜘蛛<br />
18        202.108.22.*        百度蜘蛛<br />
19        202.108.23.*        百度蜘蛛<br />
20        202.108.249.*        百度蜘蛛<br />
21        202.108.250.*        百度蜘蛛<br />
22        61.135.145.*        百度蜘蛛<br />
23        61.135.146.*        百度蜘蛛<br />
24        64.124.85.*        become.com<br />
25        61.151.243.*        china蜘蛛<br />
26        202.165.96.*        gais.cs.ccu.edu.tw<br />
27        216.239.33.*        google蜘蛛<br />
28        216.239.35.*        google蜘蛛<br />
29        216.239.37.*        google蜘蛛<br />
30        216.239.39.*        google蜘蛛<br />
31        216.239.51.*        google蜘蛛<br />
32        216.239.53.*        google蜘蛛<br />
33        216.239.55.*        google蜘蛛<br />
34        216.239.57.*        google蜘蛛<br />
35        216.239.59.*        google蜘蛛<br />
36        64.233.161.*        google蜘蛛<br />
37        64.233.189.*        google蜘蛛<br />
38        66.102.11.*        google蜘蛛<br />
39        66.102.7.*        google蜘蛛<br />
40        66.102.9.*        google蜘蛛<br />
41        66.249.64.*        google蜘蛛<br />
42        66.249.65.*        google蜘蛛<br />
43        66.249.66.*        google蜘蛛<br />
44        66.249.71.*        google蜘蛛<br />
45        66.249.72.*        google蜘蛛<br />
46        72.14.207.*        google蜘蛛<br />
47        61.135.152.*        iask蜘蛛<br />
48        65.54.188.*        msn蜘蛛<br />
49        65.54.225.*        msn蜘蛛<br />
50        65.54.226.*        msn蜘蛛<br />
51        65.54.228.*        msn蜘蛛<br />
52        65.54.229.*        msn蜘蛛<br />
53        207.46.98.*        msn蜘蛛<br />
54        207.68.157.*        msn蜘蛛<br />
55        194.224.199.*        noxtrumbot<br />
56        220.181.8.*        Outfox<br />
57        221.239.209.*        Outfox<br />
58        217.212.224.*        psbot<br />
59        219.133.40.*        QQ蜘蛛<br />
60        202.96.170.*        QQ蜘蛛<br />
61        202.104.129.*        QQ蜘蛛<br />
62        61.135.157.*        QQ蜘蛛<br />
63        219.142.118.*        sina蜘蛛<br />
64        219.142.78.*        sina蜘蛛<br />
65        61.135.132.*        sohu蜘蛛<br />
66        220.181.26.*        sohu蜘蛛<br />
          220.181.19.*<br />
67        61.135.158.*        tom蜘蛛<br />
68        66.196.90.*        yahoo蜘蛛<br />
69        66.196.91.*        yahoo蜘蛛<br />
70        68.142.249.*        yahoo蜘蛛<br />
71        68.142.250.*        yahoo蜘蛛<br />
72        68.142.251.*        yahoo蜘蛛<br />
73        202.165.102.*        yahoo中国蜘蛛<br />
74        202.160.178.*        yahoo中国蜘蛛<br />
75        202.160.179.*        yahoo中国蜘蛛<br />
76        202.160.180.*        yahoo中国蜘蛛<br />
77        202.160.181.*        yahoo中国蜘蛛<br />
78        202.160.183.*        yahoo中国蜘蛛<br />
79        72.30.101.*        yahoo蜘蛛<br />
80        72.30.102.*        yahoo蜘蛛<br />
81        72.30.103.*        yahoo蜘蛛<br />
82        72.30.104.*        yahoo蜘蛛<br />
83        72.30.107.*        yahoo蜘蛛<br />
84        72.30.110.*        yahoo蜘蛛<br />
85        72.30.111.*        yahoo蜘蛛<br />
86        72.30.128.*        yahoo蜘蛛<br />
87        72.30.129.*        yahoo蜘蛛<br />
88        72.30.131.*        yahoo蜘蛛<br />
89        72.30.133.*        yahoo蜘蛛<br />
90        72.30.134.*        yahoo蜘蛛<br />
91        72.30.135.*        yahoo蜘蛛<br />
92        72.30.216.*        yahoo蜘蛛<br />
93        72.30.226.*        yahoo蜘蛛<br />
94        72.30.252.*        yahoo蜘蛛<br />
95        72.30.97.*        yahoo蜘蛛<br />
96        72.30.98.*        yahoo蜘蛛<br />
97        72.30.99.*        yahoo蜘蛛<br />
98        74.6.74.*        yahoo蜘蛛<br />
99        202.108.4.*        中搜蜘蛛<br />
100      202.108.4.*        中搜蜘蛛<br />
101      202.108.33.*      中搜蜘蛛<br />
102      202.96.51.*        中搜蜘蛛<br />
103      219.142.53.*        中搜蜘蛛 </p>
]]></content:encoded>
			<wfw:commentRss>http://www.nimab.org/2008/08/25/51.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>交叉编译jpeg库的问题</title>
		<link>http://www.nimab.org/2008/03/11/27.html</link>
		<comments>http://www.nimab.org/2008/03/11/27.html#comments</comments>
		<pubDate>Tue, 11 Mar 2008 06:20:14 +0000</pubDate>
		<dc:creator>xdanger</dc:creator>
				<category><![CDATA[bash]]></category>

		<guid isPermaLink="false">http://www.nimab.org/2008/03/11/27.html</guid>
		<description><![CDATA[./configure --enable-shared --enable-static 加了 --enable-shared 或者 --enable-statics 就会报 ltconfig: cannot guess host type; you must specify one 方法是安装最新版的 libtool 然后 cp /usr/share/libtool/config.sub . cp /usr/share/libtool/config.guess . ./configure --enable-shared --enable-static make; make install]]></description>
			<content:encoded><![CDATA[<div class="hl-surround" style="height:28px;"><div class="hl-main"><pre>./configure --enable-shared --enable-static</pre></div></div>
<p>加了 --enable-shared 或者 --enable-statics 就会报</p>
<div class="hl-surround" style="height:28px;"><div class="hl-main"><pre>ltconfig: cannot guess host type; you must specify one</pre></div></div>
<p>方法是安装最新版的 <a href="http://ftp.gnu.org/gnu/libtool/">libtool</a> 然后</p>
<div class="hl-surround" ><div class="hl-main"><pre>cp /usr/share/libtool/config.sub . 
cp /usr/share/libtool/config.guess . 
./configure --enable-shared --enable-static 
make; make install</pre></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.nimab.org/2008/03/11/27.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Leopard 编译 universal php5</title>
		<link>http://www.nimab.org/2007/12/11/24.html</link>
		<comments>http://www.nimab.org/2007/12/11/24.html#comments</comments>
		<pubDate>Mon, 10 Dec 2007 17:02:19 +0000</pubDate>
		<dc:creator>Kafeifei</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[Bsd]]></category>
		<category><![CDATA[MacosX]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://www.nimab.org/2007/12/11/24.html</guid>
		<description><![CDATA[因为自带的php没有gd所以要重编 因为服务器用的是x86_64 httpd+php5所以要编 x86_64 因为自带的httpd+php是 universal ，所以要这样做 自带的httpd很好，所以不搞它了 参考: ppc就不要了 export MACOSX_DEPLOYMENT_TARGET=10.5 export ARCHFLAGS='-arch i386 -arch x86_64' export CFLAGS='-arch i386 -arch x86_64 -O3 -pipe' export CXXFLAGS='-arch i386 -arch x86_64 -O3 -pipe' export LDFLAGS='-arch i386 -arch x86_64 -bind_at_load' make时候可能出现这样的提示： gcc-4.0: -E, -S, -save-temps and -M options are not allowed with multiple -arch flags 在 configure 的时候加上 [...]]]></description>
			<content:encoded><![CDATA[<p>因为自带的php没有gd所以要重编<br />
因为服务器用的是x86_64 httpd+php5所以要编 x86_64<br />
因为自带的httpd+php是 universal ，所以要这样做<br />
自带的httpd很好，所以不搞它了<br />
<strong>参考:</strong><br />
ppc就不要了</p>
<blockquote><p>
export MACOSX_DEPLOYMENT_TARGET=10.5<br />
export ARCHFLAGS='-arch i386 -arch x86_64'<br />
export CFLAGS='-arch i386 -arch x86_64 -O3 -pipe'<br />
export CXXFLAGS='-arch i386 -arch x86_64 -O3 -pipe'<br />
export LDFLAGS='-arch i386 -arch x86_64 -bind_at_load'
</p></blockquote>
<p>make时候可能出现这样的提示：</p>
<blockquote><p>gcc-4.0: -E, -S, -save-temps and -M options are not allowed with multiple -arch flags</p></blockquote>
<p>在 configure 的时候加上 --disable-dependency-tracking</p>
<blockquote><p>
'./configure' \<br />
'--prefix=/usr' \<br />
'--with-config-file-path=/private/etc' \<br />
'--sysconfdir=/private/etc' \<br />
'--with-apxs2=/usr/sbin/apxs' \<br />
'--with-iconv=/usr/local' \<br />
'--with-mhash=/usr/local' \<br />
'--with-gettext=/usr/local' \<br />
'--with-mysql=/usr/local' \<br />
'--with-mysqli=/usr/local/bin/mysql_config' \<br />
'--with-pdo-mysql=/usr/local' \<br />
'--with-openssl=/usr' \<br />
'--with-zlib=/usr' \<br />
'--with-curl=/usr' \<br />
'--with-gd' \<br />
'--with-png-dir=/usr/X11' \<br />
'--with-jpeg-dir=/usr/local' \<br />
'--with-freetype-dir=/usr/X11' \<br />
'--with-xpm-dir=/usr/X11' \<br />
'--enable-gd-native-ttf' \<br />
'--enable-mbstring' \<br />
'--enable-sockets' \
</p></blockquote>
<p>已有的库就不重装了，只需自己安装 gawk, libiconv, mhash, gettext, mysql, jpeg<br />
需要特别注意：系统自带的liviconv有问题，需要自己编一份到/usr/local(小心不要覆盖以前的，否则可能连sh都不能执行了)，php在configure时就算指定了 --with-iconv=/usr/local 它还是首先找到 /usr/include/iconv.h ,而且 --help 里只提到 --with-iconv-dir=，应该使用 --with-iconv=<br />
解决方法：</p>
<blockquote><p>
sh#mv /usr/include/iconv.h /usr/include/iconv.h.bak
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.nimab.org/2007/12/11/24.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>都是dash惹的祸</title>
		<link>http://www.nimab.org/2007/03/06/18.html</link>
		<comments>http://www.nimab.org/2007/03/06/18.html#comments</comments>
		<pubDate>Tue, 06 Mar 2007 10:10:04 +0000</pubDate>
		<dc:creator>Kafeifei</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[Bsd]]></category>
		<category><![CDATA[dash]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MacosX]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://www.nimab.org/2007/03/06/18.html</guid>
		<description><![CDATA[困扰我一个春天的问题！ Ubuntu 某天下了一个nerolinux，然后安装 安装失败，提示某脚本出错，看上去是语法错误 出错嘛就删除了哦 结果删除失败，提示同样的错误 导致使用apt-get任何时候都提示这个错误 几经搞整以后造成“新立得”无法正常运行 准备好光盘准备重装了 同时继续寻找希望，搜编google没有正解 其中错误包括： dpkg (子进程)：无法执行新的 post-removal script: No such file or directory dpkg: 作下列清理工作时发生错误: 子进程·post-removal script·返回了错误号·2 在处理时有错误发生： ------------------------------------- 软件包nerolinux 需要重新安装，但是我无法找到相应的安装文件。 仔细看了一下错误文件 /var/lib/dpkg/info/nerolinux.xxx 打开一看，语法好像不太寻常，我看到了 function 字样 再看头部 #!/bin/sh 改为 #!/bin/bash 后解决问题 ls -l /bin/sh 这个东西是链接到 dash 而不是 bash的 自从ubuntu 6.10 开始就是这样，很让人头痛，很多脚本运行有问题 见过有人为了装一个软件先把 bash->sh 装完了再 dash->sh 回去 妈B的，不改回去了，也没见哪个脚本运行不正常的！ 最后，不知道这个dash是啥东东，本来想大骂一顿的，不过…… [...]]]></description>
			<content:encoded><![CDATA[<p>困扰我一个春天的问题！<br />
Ubuntu<br />
某天下了一个nerolinux，然后安装<br />
安装失败，提示某脚本出错，看上去是语法错误<br />
出错嘛就删除了哦<br />
结果删除失败，提示同样的错误<br />
导致使用apt-get任何时候都提示这个错误<br />
几经搞整以后造成“新立得”无法正常运行<br />
准备好光盘准备重装了<br />
同时继续寻找希望，搜编google没有正解<br />
其中错误包括：</p>
<blockquote><p>
dpkg (子进程)：无法执行新的 post-removal script: No such file or directory<br />
dpkg: 作下列清理工作时发生错误:<br />
子进程·post-removal script·返回了错误号·2<br />
在处理时有错误发生：<br />
-------------------------------------<br />
软件包nerolinux 需要重新安装，但是我无法找到相应的安装文件。
</p></blockquote>
<p>仔细看了一下错误文件<br />
/var/lib/dpkg/info/nerolinux.xxx<br />
打开一看，语法好像不太寻常，我看到了 function 字样<br />
再看头部 #!/bin/sh<br />
改为 #!/bin/bash 后解决问题<br />
ls -l /bin/sh 这个东西是链接到 dash 而不是 bash的<br />
自从ubuntu 6.10 开始就是这样，很让人头痛，很多脚本运行有问题<br />
见过有人为了装一个软件先把 bash->sh 装完了再 dash->sh 回去</p>
<p>妈B的，不改回去了，也没见哪个脚本运行不正常的！<br />
最后，不知道这个dash是啥东东，本来想大骂一顿的，不过…… 还是算了……</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nimab.org/2007/03/06/18.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>ssh SendEnv 问题</title>
		<link>http://www.nimab.org/2007/03/05/17.html</link>
		<comments>http://www.nimab.org/2007/03/05/17.html#comments</comments>
		<pubDate>Mon, 05 Mar 2007 03:26:24 +0000</pubDate>
		<dc:creator>Kafeifei</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MacosX]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://www.nimab.org/2007/03/05/17.html</guid>
		<description><![CDATA[远程主机不支持 zh_CN.UTF-8 我机器确是 ssh时: debug1: Sending environment. debug1: Sending env LANG = zh_CN.UTF-8 debug1: Sending env LC_CTYPE = zh_CN.UTF-8 造成远程很多程序不能运行 我认为既是远程，就不管那么多了，语言环境随它去比较好 修改 /etc/ssh/ssh_config 注销掉 SendEnv LANG LC_* 即可]]></description>
			<content:encoded><![CDATA[<p>远程主机不支持 zh_CN.UTF-8 我机器确是<br />
ssh时:</p>
<blockquote><p>debug1: Sending environment.<br />
debug1: Sending env LANG = zh_CN.UTF-8<br />
debug1: Sending env LC_CTYPE = zh_CN.UTF-8</p></blockquote>
<p>造成远程很多程序不能运行</p>
<p>我认为既是远程，就不管那么多了，语言环境随它去比较好</p>
<p>修改<br />
/etc/ssh/ssh_config<br />
注销掉 SendEnv LANG LC_*<br />
即可</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nimab.org/2007/03/05/17.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>再谈 jre / ZendStudio 中文字体问题</title>
		<link>http://www.nimab.org/2007/01/23/12.html</link>
		<comments>http://www.nimab.org/2007/01/23/12.html#comments</comments>
		<pubDate>Mon, 22 Jan 2007 17:55:14 +0000</pubDate>
		<dc:creator>Kafeifei</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[Zend]]></category>

		<guid isPermaLink="false">http://www.nimab.org/2007/01/23/12.html</guid>
		<description><![CDATA[找了若干资料，终于有了结果 原来如此简单： 把 Courier New 的几个字体文件 copy 到 jre/lib/fonts/ cd xxx/jre/lib/fonts mkfontscale cp fonts.scale fonts.dir cd ../ cp fontconfig.properties.src fontconfig.properties vi fontconfig.properties 修改相关位置： monospaced.plain.latin-1=-monotype-courier new-medium-r-normal--0-0-0-0-m-0-iso8859-1 monospaced.bold.latin-1=-monotype-courier new-bold-r-normal--0-0-0-0-m-0-iso8859-1 monospaced.italic.latin-1=-monotype-courier new-medium-i-normal--0-0-0-0-m-0-iso8859-1 monospaced.bolditalic.latin-1=-monotype-courier new-bold-i-normal--0-0-0-0-m-0-iso8859-1 最后再 cp 一个你喜欢的中文字体到 xxx/jre/fonts/fallback/ 打开 ZDE，设置字体为 monospaced 这下爽了，我顶你个肺！ 注意：此方法只在 Ubuntu 下测试通过，另外 Windows 是不适用的，如果是suse或者redhat之类的系统，主意看 xxx/jre/lib 下面的fontconfig.xxxx 文件，与当前系统相关做相应的修改就可以（没试过） 相关网址：http://java.sun.com/j2se/1.5.0/docs/guide/intl/fontconfig.html]]></description>
			<content:encoded><![CDATA[<p>找了若干资料，终于有了结果<br />
原来如此简单：</p>
<p>把 Courier New 的几个字体文件 copy 到 jre/lib/fonts/ </p>
<blockquote><p>
cd xxx/jre/lib/fonts<br />
mkfontscale<br />
cp fonts.scale fonts.dir<br />
cd ../<br />
cp fontconfig.properties.src fontconfig.properties<br />
vi fontconfig.properties
</p></blockquote>
<p>修改相关位置：</p>
<blockquote><p>
monospaced.plain.latin-1=-monotype-courier new-medium-r-normal--0-0-0-0-m-0-iso8859-1<br />
monospaced.bold.latin-1=-monotype-courier new-bold-r-normal--0-0-0-0-m-0-iso8859-1<br />
monospaced.italic.latin-1=-monotype-courier new-medium-i-normal--0-0-0-0-m-0-iso8859-1<br />
monospaced.bolditalic.latin-1=-monotype-courier new-bold-i-normal--0-0-0-0-m-0-iso8859-1
</p></blockquote>
<p>最后再 cp 一个你喜欢的中文字体到 xxx/jre/fonts/fallback/<br />
打开 ZDE，设置字体为 monospaced<br />
这下爽了，我顶你个肺！</p>
<p>注意：此方法只在 Ubuntu 下测试通过，另外 Windows 是不适用的，如果是suse或者redhat之类的系统，主意看 xxx/jre/lib 下面的fontconfig.xxxx 文件，与当前系统相关做相应的修改就可以（没试过）</p>
<p>相关网址：<a href="http://java.sun.com/j2se/1.5.0/docs/guide/intl/fontconfig.html">http://java.sun.com/j2se/1.5.0/docs/guide/intl/fontconfig.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nimab.org/2007/01/23/12.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>bash 中的正则表达式</title>
		<link>http://www.nimab.org/2006/09/13/4.html</link>
		<comments>http://www.nimab.org/2006/09/13/4.html#comments</comments>
		<pubDate>Wed, 13 Sep 2006 13:18:30 +0000</pubDate>
		<dc:creator>Kafeifei</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.nimab.org/2006/09/13/4.html</guid>
		<description><![CDATA[类似 $ps ax &#124; grep -v grep &#124; grep httpd &#124; tr -s ' ' &#124; cut -d ' ' -f1 的方法来取得pid确实还挺好用的，不过今天要取得这个程序执行了多长时间，这个就麻烦了，因为时间中间有空格 翻了半天的man还是没好的解决方案，换了台机器，ubuntu 的，发现 ps 有不小的区别，可以这样： $ps -eo pid,lstart,args &#124; grep httpd &#124; grep -v grep 2374 Wed Sep 13 00:41:59 2006 /usr/local/httpd/bin/httpd -k restart 2469 Wed Sep 13 00:42:03 2006 /usr/local/httpd/bin/httpd -k restart 22470 [...]]]></description>
			<content:encoded><![CDATA[<p>类似</p>
<blockquote><p>$ps ax | grep -v grep | grep httpd | tr -s ' ' | cut -d ' ' -f1</p></blockquote>
<p>的方法来取得pid确实还挺好用的，不过今天要取得这个程序执行了多长时间，这个就麻烦了，因为时间中间有空格<br />
翻了半天的man还是没好的解决方案，换了台机器，ubuntu 的，发现 ps 有不小的区别，可以这样：</p>
<blockquote><p>$ps -eo pid,lstart,args | grep httpd | grep -v grep<br />
 2374 Wed Sep 13 00:41:59 2006 /usr/local/httpd/bin/httpd -k restart<br />
 2469 Wed Sep 13 00:42:03 2006 /usr/local/httpd/bin/httpd -k restart<br />
22470 Wed Sep 13 00:42:03 2006 /usr/local/httpd/bin/httpd -k restart<br />
22472 Wed Sep 13 00:42:03 2006 /usr/local/httpd/bin/httpd -k restart<br />
22474 Wed Sep 13 00:42:03 2006 /usr/local/httpd/bin/httpd -k restart</p></blockquote>
<p>其中最前面的数字是pid 中间 Wed Sep 13 00:41:59 2006 是开始时间，后面的所有是"args" (linux下面的ps有lstart这个参数)<br />
这个就麻烦了，args自然只是为了匹配进程特征，中间的时间才是我要的东西。<br />
再找找关于grep的说明（这些小工具都强到一种境界，据说一个sed就写了一本书），一个 -o 参数搞定</p>
<blockquote><p>$pid=ps -eo pid,lstart,args | grep httpd | grep -v grep | egrep -o ^\ ?[0-9]+\ </p></blockquote>
<p>注意最后有一个空格 "\ " 这样比较保险一点<br />
发现出来的内容</p>
<blockquote><p>
 2374<br />
 2469<br />
22470<br />
22472<br />
22474
</p></blockquote>
<p>有空格，加一个 tr：</p>
<blockquote><p>$pid=ps -eo pid,lstart,args | grep httpd | grep -v grep | egrep -o ^\ ?[0-9]+\ | tr -d ' '</p></blockquote>
<p>同理时间也就简单了：</p>
<blockquote><p>$ps -eo pid,lstart,args | grep httpd | grep -v grep | egrep -o \ [A-Z][a-zA-Z0-9\ :]+\ [0-9]{4}</p></blockquote>
<p>转换成时间戳：</p>
<blockquote><p>$ps -eo pid,lstart,args | grep httpd | grep -v grep | egrep -o \ [A-Z][a-zA-Z0-9\ :]+\ [0-9]{4} | ......</p></blockquote>
<p>操，卡住了，做的时候都是传的变量。。。</p>
<p>幸好高人(hightman)指点</p>
<blockquote><p>$ps -eo pid,lstart,args | grep httpd | grep -v grep | egrep -o \ [A-Z][a-zA-Z0-9\ :]+\ [0-9]{4} | xargs -ishit date -d "shit" +%s<br />
1157349945<br />
1158050727<br />
1158144618<br />
1158145964<br />
1158147191
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.nimab.org/2006/09/13/4.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

