Tools for Manipulating Object Files

 

There are a number of tools available on Unix systems to help you understand and manipulate object files. In particular, the GNU binutils package is especially helpful and runs on every Unix platform.

 

  1. AR : Creates static libraries, and inserts, deletes, lists, and extracts members.
  2. STRINGS: Lists all of the printable strings contained in an object file.
  3. STRIP: Deletes symbol table information from an object file.
  4. NM : Lists the symbols defined in the symbol table of an object file.
  5. SIZE: Lists the names and sizes of the sections in an object file.
  6. READELF: Displays the complete structure of an object file, including all of the information encoded in the ELF header. Subsumes the functionality of SIZE and NM.
  7. OBJDUMP: The mother of all binary tools. Can display all of the information in an object file. Its most useful function is disassembling the binary instructions in the .text section.
  8. LDD : Lists the shared libraries that an executable needs at run time.
--- From Computer Systems: A Programmer's Perspective.

PS:

  1. A very good webpage introducing Linux libraries: Static, Shared Dynamic and Loadable Linux Libraries
  2. How to Write Shared Libraries? http://www.akkadia.org/drepper/dsohowto.pdf
  3. Program Library HOWTO: http://tldp.org/HOWTO/Program-Library-HOWTO/index.html

Commenting out a range of lines in VIM

Reference: http://vim.wikia.com/wiki/Commenting_out_a_range_of_lines

 

A -VISUAL BLOCK- can also be used to comment out lines. 

 

Start by typing "Ctrl-V" and then highlight a strip downwards by hitting "down/j".

 

After that, type capital "I" to insert for all highlighted lines. Type the comment, in this case "#<Space>". Then hit "Esc".

如何查看Ksh Version

  1. echo $KSH_VERSION. 若没有输出,echo ${.sh.version},Ksh93有效
  2. /bin/ksh --version 应该只在Linux下有效
  3. strings /bin/ksh | grep -i version,直接到二进制文件里查找
  4. set -o vi ;ESC;Ctrl+V,详见http://unix.ittoolbox.com/groups/technical-functional/shellscript-l/command-to-find-the-version-of-ksh-1490264

对于KSH88,估计只有3、4有效。

利用在线词典批量查询英语单词

进来遇到很多英语生词,工具书上给的解释错误百出,而很多在线词典不但可以给出某个单词的解释,而且有大量的示例,因此猜想利用在线词典批量查询这些单词。怎么实现呢?

首要问题是如何自动获取某个单词的解释。搜索之后,发现可以用curl实现,如

curl -s "http://www.google.com/dictionary?aq=f&langpair=en|en&q="$1"&hl=en" | html2text -nobs | sed '1,/^ *Dictionary/]/d' | head -n -5 | less

 

请参见http://ubuntuforums.org/showthread.php?t=1591389 和 http://stackoverflow.com/questions/1617152/using-google-as-a-dictionary-lookup-via-bash-how-can-one-grab-the-first-definiti

 

试过Google Dictionary之后发现, curl下来的网页用html2text转换时会报错:Input recoding failed due to invalid input sequence. 尝试了Python版的html2text之后,依然有大量的javascript和HTML代码残留。于是转而求助于百度词典——因为百度词典的搜索结果中没有Javascript语句,html2text一般可以完美转换。

 

转换完之后的文件如下,编码为UTF-8.

�新闻   网页   贴吧   知道   MP3   图片   视频   词典   
            [antiseptic                                ] 设置 | 帮助
               [查百度词典]   
                                     把百度设为首页
语法标注解释 antiseptic英音:[,ænti'septik]美音:[,æntə'sɛptɪk]
 
*****   *****
**** 以下结果由[bddict/source/img/logo.gif]译典通提供词典解释 ****
形容词 a.
1.
抗菌的,防腐的
2.
使用抗菌剂的,使用防腐剂的
antiseptic treatment
防腐处理
3.
未受感染的,无菌的,消过毒的
The technician had on an antiseptic white jacket.
那个技术员穿着消毒白色夹克。
4.
非常整洁的
5.
冷淡的,缺乏热情的
He nodded an antiseptic greeting.
他冷冷地点头打了个招呼。
名词 n.
1.
抗菌剂,防腐剂[C]
**** 以下结果来自互联网网络释义 ****
antiseptic
1.
防腐剂/消毒药
大学英语相似词辨析(13):ante-,a...
antiseptic 防腐剂/消毒药
http://www.english-ex...
2.
防霉剂
北京译邦达翻译公司-2008 Januar...
防霉剂 antiseptic
http://www.t-bond.com...
3.
防腐的;防腐剂
石油英语|能源动力行业英语第1521页
antiseptic防腐的;防腐剂
http://www.b2b99.com/...
4.
抗菌剂, 防腐剂
SAT化学词汇表Chapter 6_SAT...
antiseptic抗菌剂, 防腐剂
http://www.24en.com/s...
Antiseptic
1.
防腐剂
词博英语社区(生物词汇 A-F (1)[c...
Antiseptic 防腐剂
http://www.cibo.biz/f...
 显示更多网络释义结果
©2011 Baidu 此内容系百度根据您的指令自动搜索的结果,不代表百度赞成被搜索网站的内容或立场
[http://c.baidu.com/c.gif?t=0&q=antiseptic&p=0&pn=0]
      [wd                  ] [s]
**** 搜索框提示 ****
*** 是否希望搜索汉字和英语时显示搜索框提示 ***
 #显示 o不显示
[Unknown INPUT type]

 

 

显然上面的内容是不便于阅读的。为了提取有用信息,需要对上面的内容进行处理——下面的脚本参考了http://blog.csdn.net/jallin2001/archive/2009/11/13/4808618.aspx

 

#!/usr/bin/perl -w
############### censor.pl #################
# Handle the explanations got from online dictionary.
# Inputs:
#	ARGV[0] -- temparory file containning the explanations
#	ARGV[1] -- keyword
############################################
use strict;
use Encode;
my $syntax = Encode::decode('utf8', '语法标注解释 ');
my $internet = Encode::decode('utf8', '以下结果来自互联网网络释义');
my $yingyin = Encode::decode('utf8', '英音');
my $meiyin = Encode::decode('utf8', '美音');
my $write_flag=0;
open(EXP,$ARGV[0]);
while (my $nextline=<EXP>) {
	chomp($nextline);
	$nextline = Encode::decode('utf8', $nextline);
	if ($nextline =~ m/.*$syntax.*/) {
		$write_flag=1;
		$nextline =~ s/$syntax//;
	} elsif ($nextline =~ m/.*$internet.*/) {
		$write_flag=0;
	}
			
	if ($write_flag eq 1) {
		if ($nextline !~ m/.*/*/*/*/*.*/) { # Excluse lines containning ****
			# Add a space between the keyword and 英音/美音
			$nextline =~ s/$ARGV[1]([$yingyin|$meiyin])/$ARGV[1] $1/; 
			print encode("utf8",$nextline),"/r/n"; # In perl, /r/n is needed to add a new line
		}
	}
}

运行上面的脚本后,可以得到如下的输出:

antiseptic 英音:[,ænti'septik]美音:[,æntə'sɛptɪk]
 
形容词 a.
1.
抗菌的,防腐的
2.
使用抗菌剂的,使用防腐剂的
antiseptic treatment
防腐处理
3.
未受感染的,无菌的,消过毒的
The technician had on an antiseptic white jacket.
那个技术员穿着消毒白色夹克。
4.
非常整洁的
5.
冷淡的,缺乏热情的
He nodded an antiseptic greeting.
他冷冷地点头打了个招呼。
名词 n.
1.
抗菌剂,防腐剂[C]

 

另外,如果要自动化查询一批英文单词,可以把它们写到一个文件中,然后用下面的脚本进行自动查询

#!/bin/bash
# Command line look up using Google's define feature - command line dictionary
WORDS=$(cat ./words)
for word in $WORDS
do
#	word=$1
	#curl -s -A 'Mozilla/4.0'  'http://www.google.com/dictionary?langpair=zh-CN|en&hl=en&aq=f&q='$word >> test.html
	curl -s -A 'Mozilla/4.0' "http://dict.baidu.com/s?tn=dict&wd="$word | html2text > tmp 2>/dev/null
	echo "------------------ $word -------------------" >> mywords
	./censor.pl tmp $word >> mywords
	rm -f tmp
done

 

Update 2011-01-02:

 

终于找到了查询Google Dictionary的一种方法。

Google Dictionary对于单词abandon的解释可以利用URL:http://www.google.com/dictionary?langpair=en|zh-CN&q=abandon&hl=en&aq=f 得到,而网页的信息如下:

 

 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<mce:script type="text/javascript"><!--
 
(function(){function a(d){this.t={};this.tick=function(e,f,b){b=b?b:(new Date).getTime();this.t[e]=[b,f]};this.tick("start",null,d)}var c=new a;window.jstiming={Timer:a,load:c};try{var g=null;if(window.chrome&&window.chrome.csi)g=Math.floor(window.chrome.csi().pageT);if(g==null)if(window.gtbExternal)g=window.gtbExternal.pageT();if(g==null)if(window.external)g=window.external.pageT;if(g)window.jstiming.pt=g}catch(h){};})();
// --></mce:script> 
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> 
<meta name="keywords" content="dictionary, dict, language, translate, translation, define, definition, glossary, online dictionary, language tool, multilingual dictionary of abandon , Arabic, Bengali, Bulgarian, Chinese (Simplified), Chinese (Traditional), Croatian, Czech, Dutch, English, Finnish, French, German, Greek, Gujarati, Hebrew, Hindi, Italian, Kannada, Korean, Malayalam, Marathi, Portuguese, Russian, Serbian, Spanish, Tamil, Telugu, Thai"> 
<meta name="description" content="abandon : (不顾责任、义务等)离弃,遗弃,抛弃, 不得已而放弃;舍弃, 停止(支持或帮助);放弃(信念), 中止;放弃;不再有, 陷入,沉湎于(某种情感), 放任;放纵 - Google's free online dictionary service."> 
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"> 
<link rel="canonical" href="/dictionary?hl=en&sl=en&tl=zh-CN&q=abandon" mce_href="dictionary?hl=en&sl=en&tl=zh-CN&q=abandon"> 
<title> 
abandon in Chinese (Simplified) - Google Dictionary
</title> 
<link rel="stylesheet" href="/dictionary/css/google-common_post20090706.css" mce_href="dictionary/css/google-common_post20090706.css" type="text/css"> 
<mce:style type="text/css"><!--
  
  #gbar,#guser{font-size:13px;padding-right:1px;padding-top:2px !important}#gbar{padding-left:1px;float:left;height:22px}#guser{padding-bottom:7px !important;text-align:right}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}#gbs,.gbm{background:#fff;left:0;position:absolute;text-align:left;visibility:hidden;z-index:1000}.gbm{border:1px solid;border-color:#c9d7f1 #36c #36c #a2bae7;z-index:1001}.gb1{margin-right:.5em}#gbar .gbsup{color:#c00;font-size:9px;font-weight:normal;line-height:9px;margin-left:-.5em;margin-right:.5em;*margin-left:-.5em;*margin-right:.5em}.gb1,.gb3{zoom:1}.gb2{display:block;padding:.2em .5em}.gb2,.gb3{text-decoration:none;border-bottom:none}a.gb1,a.gb2,a.gb3,a.gb4{color:#00c !important}.gbi .gb3,.gbi .gb2,.gbi .gb4{color:#dd8e27 !important}.gbf .gb3,.gbf .gb2,.gbf .gb4{color:#900 !important}a.gb2:hover{background:#36c;color:#fff !important}
--></mce:style><style type="text/css" mce_bogus="1">  
  #gbar,#guser{font-size:13px;padding-right:1px;padding-top:2px !important}#gbar{padding-left:1px;float:left;height:22px}#guser{padding-bottom:7px !important;text-align:right}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}#gbs,.gbm{background:#fff;left:0;position:absolute;text-align:left;visibility:hidden;z-index:1000}.gbm{border:1px solid;border-color:#c9d7f1 #36c #36c #a2bae7;z-index:1001}.gb1{margin-right:.5em}#gbar .gbsup{color:#c00;font-size:9px;font-weight:normal;line-height:9px;margin-left:-.5em;margin-right:.5em;*margin-left:-.5em;*margin-right:.5em}.gb1,.gb3{zoom:1}.gb2{display:block;padding:.2em .5em}.gb2,.gb3{text-decoration:none;border-bottom:none}a.gb1,a.gb2,a.gb3,a.gb4{color:#00c !important}.gbi .gb3,.gbi .gb2,.gbi .gb4{color:#dd8e27 !important}.gbf .gb3,.gbf .gb2,.gbf .gb4{color:#900 !important}a.gb2:hover{background:#36c;color:#fff !important}</style> 
<link rel="stylesheet" href="/dictionary/css/dictionary-search_post20100310.css" mce_href="dictionary/css/dictionary-search_post20100310.css" type="text/css"> 
<link rel="stylesheet" href="/dictionary/css/gselectbox_post20090113.css" mce_href="dictionary/css/gselectbox_post20090113.css" type="text/css"> 
<mce:script type="text/javascript" src="/dictionary/js/dictionary_compiled_post20091026.js" mce_src="dictionary/js/dictionary_compiled_post20091026.js"><!--
 
// --></mce:script> 
<mce:script type="text/javascript"><!--
 
(function(){function i(a,b,c){var d="on"+b;if(a.addEventListener)a.addEventListener(b,c,false);else if(a.attachEvent)a.attachEvent(d,c);else{var h=a[d];a[d]=function(){var g=h.apply(this,arguments),e=c.apply(this,arguments);return g==undefined?e:e==undefined?g:e&&g}}};var j,k,l,m=window.gbar={};function _tvs(a,b){return a||b}function _tvn(a,b){var c=parseInt(a,10);return isNaN(c)?b:c}function _tvf(a,b){var c=parseFloat(a);return isNaN(c)?b:c}function _tvb(a,b){return a=="true"?true:a=="false"?false:b}var n,o,p;function q(a){var b=window.a&&(document.forms[0].b||"").value;if(b)a.href=a.href.replace(/([?&])q=[^&]*|$/,function(c,d){return(d||"&")+"q="+encodeURIComponent(b)})}l=q;
function r(a,b,c,d,h,g){var e=document.getElementById(a);if(e){var f=e.style;f.left=d?"auto":b+"px";f.right=d?b+"px":"auto";f.top=c+"px";f.visibility=o?"hidden":"visible";if(h&&g){f.width=h+"px";f.height=g+"px"}else{r(n,b,c,d,e.offsetWidth,e.offsetHeight);o=o?"":a}}}
var s=[],v=function(a){a=a||window.event;var b=a.target||a.srcElement;a.cancelBubble=true;if(n==null){a=document.createElement(Array.every||window.createPopup?"iframe":"div");a.frameBorder="0";n=a.id="gbs";a.src="javascript:''";b.parentNode.appendChild(a);i(document,"click",t)}var c=b;b=0;if(c.className!="gb3")c=c.parentNode;a=c.getAttribute("aria-owns")||"gbi";var d=c.offsetWidth,h=c.offsetTop>20?46:24;if(document.getElementById("tphdr"))h-=3;var g=false;do b+=c.offsetLeft||0;while(c=c.offsetParent);
c=(document.documentElement.clientWidth||document.body.clientWidth)-b-d;var e;d=document.body;var f=document.defaultView;if(f&&f.getComputedStyle){if(d=f.getComputedStyle(d,""))e=d.direction}else e=d.currentStyle?d.currentStyle.direction:d.style.direction;e=e=="rtl";if(a=="gbi"){for(d=0;f=s[d++];)f();u(null,window.navExtra);if(e){b=c;g=true}}else if(!e){b=c;g=true}o!=a&&t();r(a,b,h,g)},t=function(){o&&r(o,0,0)},u=function(a,b){var c,d=document.getElementById("gbi"),h=a;if(!h)h=d.firstChild;for(;b&&
(c=b.pop());){var g=d,e=c,f=h;p||(p="gb2");g.insertBefore(e,f).className=p}},w=function(a,b,c){if((b=document.getElementById(b))&&a){a.className="gb4";var d=document.createElement("span");d.appendChild(a);d.appendChild(document.createTextNode(" | "));d.id=c;b.appendChild(d)}};m.qs=l;m.setContinueCb=k;m.pc=j;m.tg=v;m.close=t;m.addLink=w;m.almm=u;})();
// --></mce:script> 
<mce:script type="text/javascript" src="/dictionary/js/autocomplete_compiled_post20090416.js" mce_src="dictionary/js/autocomplete_compiled_post20090416.js"><!--
 
// --></mce:script> 
</head> 
<body onload="document.f.q.select();tickBodyLoadAndReport();" bgcolor="#ffffff" > 
<div id=gbar><nobr><a href="http://www.google.com/search?langpair=en%7Czh-CN&q=abandon&hl=en&sa=N&tab=Dw" mce_href="http://www.google.com/search?langpair=en%7Czh-CN&q=abandon&hl=en&sa=N&tab=Dw" onclick=gbar.qs(this) class=gb1>Web</a> <a href="http://www.google.com/images?langpair=en%7Czh-CN&q=abandon&hl=en&source=og&sa=N&tab=Di" mce_href="http://www.google.com/images?langpair=en%7Czh-CN&q=abandon&hl=en&source=og&sa=N&tab=Di" onclick=gbar.qs(this) class=gb1>Images</a> <a href="http://www.google.com/search?langpair=en%7Czh-CN&q=abandon&hl=en&tbo=u&tbs=vid:1&source=og&sa=N&tab=Dv" mce_href="http://www.google.com/search?langpair=en%7Czh-CN&q=abandon&hl=en&tbo=u&tbs=vid:1&source=og&sa=N&tab=Dv" onclick=gbar.qs(this) class=gb1>Videos</a> <a href="http://maps.google.com/maps?langpair=en%7Czh-CN&q=abandon&hl=en&sa=N&tab=Dl" mce_href="http://maps.google.com/maps?langpair=en%7Czh-CN&q=abandon&hl=en&sa=N&tab=Dl" onclick=gbar.qs(this) class=gb1>Maps</a> <a href="http://www.google.com/search?langpair=en%7Czh-CN&q=abandon&hl=en&tbo=u&tbs=nws:1&source=og&sa=N&tab=Dn" mce_href="http://www.google.com/search?langpair=en%7Czh-CN&q=abandon&hl=en&tbo=u&tbs=nws:1&source=og&sa=N&tab=Dn" onclick=gbar.qs(this) class=gb1>News</a> <a href="http://www.google.com/search?langpair=en%7Czh-CN&q=abandon&hl=en&tbo=u&tbs=shop:1&source=og&sa=N&tab=Df" mce_href="http://www.google.com/search?langpair=en%7Czh-CN&q=abandon&hl=en&tbo=u&tbs=shop:1&source=og&sa=N&tab=Df" onclick=gbar.qs(this) class=gb1>Shopping</a> <a href="http://mail.google.com/mail/?hl=en&tab=Dm" mce_href="http://mail.google.com/mail/?hl=en&tab=Dm" class=gb1>Gmail</a> <a href="http://www.google.com/intl/en/options/" mce_href="http://www.google.com/intl/en/options/" onclick="this.blur();gbar.tg(event);return !1" aria-haspopup=true class=gb3><u>more</u> <small>▼</small></a><div class=gbm id=gbi><a href="http://www.google.com/search?langpair=en%7Czh-CN&q=abandon&hl=en&tbo=u&tbs=bks:1&source=og&sa=N&tab=Dp" mce_href="http://www.google.com/search?langpair=en%7Czh-CN&q=abandon&hl=en&tbo=u&tbs=bks:1&source=og&sa=N&tab=Dp" onclick=gbar.qs(this) class=gb2>Books</a> <a href="http://www.google.com/finance?langpair=en%7Czh-CN&q=abandon&hl=en&sa=N&tab=De" mce_href="http://www.google.com/finance?langpair=en%7Czh-CN&q=abandon&hl=en&sa=N&tab=De" onclick=gbar.qs(this) class=gb2>Finance</a> <a href="http://translate.google.com/translate_t?langpair=en%7Czh-CN&q=abandon&hl=en&sa=N&tab=DT" mce_href="http://translate.google.com/translate_t?langpair=en%7Czh-CN&q=abandon&hl=en&sa=N&tab=DT" onclick=gbar.qs(this) class=gb2>Translate</a> <a href="http://scholar.google.com/scholar?langpair=en%7Czh-CN&q=abandon&hl=en&sa=N&tab=Ds" mce_href="http://scholar.google.com/scholar?langpair=en%7Czh-CN&q=abandon&hl=en&sa=N&tab=Ds" onclick=gbar.qs(this) class=gb2>Scholar</a> <a href="http://www.google.com/search?langpair=en%7Czh-CN&q=abandon&hl=en&tbo=u&tbs=blg:1&source=og&sa=N&tab=Db" mce_href="http://www.google.com/search?langpair=en%7Czh-CN&q=abandon&hl=en&tbo=u&tbs=blg:1&source=og&sa=N&tab=Db" onclick=gbar.qs(this) class=gb2>Blogs</a> <a href="http://www.google.com/search?langpair=en%7Czh-CN&q=abandon&hl=en&tbo=u&tbs=mbl:1&source=og&sa=N&tab=DY" mce_href="http://www.google.com/search?langpair=en%7Czh-CN&q=abandon&hl=en&tbo=u&tbs=mbl:1&source=og&sa=N&tab=DY" onclick=gbar.qs(this) class=gb2>Realtime</a> <div class=gb2><div class=gbd></div></div><a href="http://www.youtube.com/results?langpair=en%7Czh-CN&q=abandon&hl=en&sa=N&tab=D1" mce_href="http://www.youtube.com/results?langpair=en%7Czh-CN&q=abandon&hl=en&sa=N&tab=D1" onclick=gbar.qs(this) class=gb2>YouTube</a> <a href="http://www.google.com/calendar/render?hl=en&tab=Dc" mce_href="http://www.google.com/calendar/render?hl=en&tab=Dc" class=gb2>Calendar</a> <a href="http://picasaweb.google.com/lh/view?langpair=en%7Czh-CN&q=abandon&hl=en&sa=N&tab=Dq" mce_href="http://picasaweb.google.com/lh/view?langpair=en%7Czh-CN&q=abandon&hl=en&sa=N&tab=Dq" onclick=gbar.qs(this) class=gb2>Photos</a> <a href="http://docs.google.com/?hl=en&tab=Do&authuser=0" mce_href="http://docs.google.com/?hl=en&tab=Do&authuser=0" class=gb2>Documents</a> <a href="http://www.google.com/reader/view/?hl=en&tab=Dy" mce_href="http://www.google.com/reader/view/?hl=en&tab=Dy" class=gb2>Reader</a> <a href="http://sites.google.com/?hl=en&tab=D3" mce_href="http://sites.google.com/?hl=en&tab=D3" class=gb2>Sites</a> <a href="http://groups.google.com/groups?langpair=en%7Czh-CN&q=abandon&hl=en&sa=N&tab=Dg" mce_href="http://groups.google.com/groups?langpair=en%7Czh-CN&q=abandon&hl=en&sa=N&tab=Dg" onclick=gbar.qs(this) class=gb2>Groups</a> <div class=gb2><div class=gbd></div></div><a href="http://www.google.com/intl/en/options/" mce_href="http://www.google.com/intl/en/options/" class=gb2>even more »</a> </div></nobr></div><div id=guser width=100%><nobr><span id=gbn class=gbi></span><span id=gbf class=gbf></span><b class=gb4>bonny95@gmail.com</b> | <span id=gbe></span><a id="gb_67" href="http://www.google.com/history/?hl=en" mce_href="http://www.google.com/history/?hl=en" class=gb4>Web History</a> | <a id="gb_97" href="https://www.google.com/accounts/ManageAccount?hl=en" mce_href="https://www.google.com/accounts/ManageAccount?hl=en" class=gb4>My Account</a> | <a id="gb_71" href="http://www.google.com/accounts/Logout?continue=http://www.google.com/dictionary%3Flangpair%3Den%257Czh-CN%26q%3Dabandon%26hl%3Den%26aq%3Df" mce_href="http://www.google.com/accounts/Logout?continue=http://www.google.com/dictionary%3Flangpair%3Den%257Czh-CN%26q%3Dabandon%26hl%3Den%26aq%3Df" class=gb4>Sign out</a></nobr></div><div class=gbh style=left:0></div><div class=gbh style=right:0></div> 
<div id=cnt> 
<table class="tb" style="clear:both" mce_style="clear:both" width="100%"> 
<tr> 
<form name="f" action="/dictionary"> 
<td class="tc" valign="top"> 
<a id="logo" href="http://www.google.com/webhp?hl=en" mce_href="http://www.google.com/webhp?hl=en" title="Go to Google Home"> 
Go to Google Home<span></span> 
</a> 
</td> 
<td style="padding:25px 0 7px 8px;position:relative;" mce_style="padding:25px 0 7px 8px;position:relative;" valign="top" width="100%"> 
<select id="dct-slc" name="langpair" onchange="onUpdateLangpair(this)"> 
<option value="ar|en">Arabic <> English</option> 
<option value="bn|en">Bengali <> English</option> 
<option value="bg|en">Bulgarian <> English</option> 
<option value="zh-CN|zh-CN">Chinese (Simplified) dictionary</option> 
<option value="zh-CN|en">Chinese (Simplified) <> English</option> 
<option value="zh-TW|zh-TW">Chinese (Traditional) dictionary</option> 
<option value="zh-TW|en">Chinese (Traditional) <> English</option> 
<option value="hr|en">Croatian <> English</option> 
<option value="cs|cs">Czech dictionary</option> 
<option value="cs|en">Czech <> English</option> 
<option value="nl|nl">Dutch dictionary</option> 
<option value="en|ar">English <> Arabic</option> 
<option value="en|bn">English <> Bengali</option> 
<option value="en|bg">English <> Bulgarian</option> 
<option selected  value="en|zh-CN">English <> Chinese (Simplified)</option> 
<option value="en|zh-TW">English <> Chinese (Traditional)</option> 
<option value="en|hr">English <> Croatian</option> 
<option value="en|cs">English <> Czech</option> 
<option value="en|en">English dictionary</option> 
<option value="en|fi">English <> Finnish</option> 
<option value="en|fr">English <> French</option> 
<option value="en|de">English <> German</option> 
<option value="en|el">English <> Greek</option> 
<option value="en|gu">English <> Gujarati</option> 
<option value="en|iw">English <> Hebrew</option> 
<option value="en|hi">English <> Hindi</option> 
<option value="en|it">English <> Italian</option> 
<option value="en|kn">English <> Kannada</option> 
<option value="en|ko">English <> Korean</option> 
<option value="en|ml">English <> Malayalam</option> 
<option value="en|mr">English <> Marathi</option> 
<option value="en|pt">English <> Portuguese</option> 
<option value="en|ru">English <> Russian</option> 
<option value="en|sr">English <> Serbian</option> 
<option value="en|es">English <> Spanish</option> 
<option value="en|ta">English <> Tamil</option> 
<option value="en|te">English <> Telugu</option> 
<option value="en|th">English <> Thai</option> 
<option value="fi|en">Finnish <> English</option> 
<option value="fr|en">French <> English</option> 
<option value="fr|fr">French dictionary</option> 
<option value="de|en">German <> English</option> 
<option value="de|de">German dictionary</option> 
<option value="el|en">Greek <> English</option> 
<option value="gu|en">Gujarati <> English</option> 
<option value="iw|en">Hebrew <> English</option> 
<option value="hi|en">Hindi <> English</option> 
<option value="it|en">Italian <> English</option> 
<option value="it|it">Italian dictionary</option> 
<option value="kn|en">Kannada <> English</option> 
<option value="ko|en">Korean <> English</option> 
<option value="ko|ko">Korean dictionary</option> 
<option value="ml|en">Malayalam <> English</option> 
<option value="mr|en">Marathi <> English</option> 
<option value="pt|en">Portuguese <> English</option> 
<option value="pt|pt">Portuguese dictionary</option> 
<option value="ru|en">Russian <> English</option> 
<option value="ru|ru">Russian dictionary</option> 
<option value="sr|en">Serbian <> English</option> 
<option value="es|en">Spanish <> English</option> 
<option value="es|es">Spanish dictionary</option> 
<option value="ta|en">Tamil <> English</option> 
<option value="te|en">Telugu <> English</option> 
<option value="th|en">Thai <> English</option> 
</select> 
<mce:script type="text/javascript"><!--
 
if (!window.google) { window.google = {}; }
var installLanguageSelection = function() {
var language_code = {
'ar':'Arabic',
'bn':'Bengali',
'bg':'Bulgarian',
'zh-CN':'Chinese (Simplified)',
'zh-TW':'Chinese (Traditional)',
'hr':'Croatian',
'cs':'Czech',
'nl':'Dutch',
'en':'English',
'fi':'Finnish',
'fr':'French',
'de':'German',
'el':'Greek',
'gu':'Gujarati',
'iw':'Hebrew',
'hi':'Hindi',
'it':'Italian',
'kn':'Kannada',
'ko':'Korean',
'ml':'Malayalam',
'mr':'Marathi',
'pt':'Portuguese',
'ru':'Russian',
'sr':'Serbian',
'es':'Spanish',
'ta':'Tamil',
'te':'Telugu',
'th':'Thai'
};
window.google.installLanguageSelect('dct-slc', language_code);
};
window.setTimeout(installLanguageSelection, 10);
// --></mce:script> 
<input autocomplete="off" type="text" name="q" size="40" maxlength="2048"
             value="abandon"
         title="Search Dictionary"> 
<input type="hidden" name="hl"
             value="en"> 
<input type="submit" value="Search Dictionary"
         style="padding:0 .25em 0 .25em; width:auto; overflow:visible"> 
</td> 
</form> 
</tr> 
</table> 
<table width="100%" cellspacing="0" cellpadding="0" border="0" class="t bt"> 
<tbody> 
<tr> 
<td style="white-space:nowrap" mce_style="white-space:nowrap"> 
<span id="sd" style="float:left" mce_style="float:left">Dictionary</span> 
<a id="dct-clk-a"> 
<div id="dct-clk-im"><!- ie6 doesn't allow empty div. -></div> 
<span id="dct-clk-show">Show examples</span> 
<span id="dct-clk-hide">Hide examples</span> 
</a> 
</td> 
<td style="white-space:nowrap" mce_style="white-space:nowrap" align="right"> 
</td> 
</tr> 
</tbody> 
</table> 
<div class="dct-srch-otr"> 
<div class="dct-srch-inr rt-sct-exst"> 
<div class="dct-srch-rslt"> 
<p>Found in dictionary: <b>English > Chinese (Simplified)</b>.
</p> 
<ul class="dct-e2" id="pr-root" > 
<li class="dct-eh"
             > 
<div  class="dct-eh"> 
<span class="wl-st" id="wl-st-number1"
      onclick="window.google.addWord('abandon','en|zh-CN','number1');"><img alt="Add star"
    src="/dictionary/image/unstarred.gif" mce_src="dictionary/image/unstarred.gif"></span><span class="wl-ust"
  id="wl-ust-number1" onclick="window.google.removeWord('abandon','en|zh-CN','number1');"><img alt="Remove star"
    src="/dictionary/image/starred.gif" mce_src="dictionary/image/starred.gif"></span> 
<mce:script type="text/javascript"><!--
window.google.lookupWord('abandon','en|zh-CN','number1');
// --></mce:script> 
<span class="dct-tt">abandon</span><span class="dct-tp">   </span><span class="dct-tp">/əˈbændən/
<span class="dct-tlb" title="Phonetic">DJ</span></span><span class="prn-btn">/dictionary/flash/SpeakerApp16.swf</span><span class="dct-tp">   </span><span class="dct-tp">/ə'bændən/
<span class="dct-tlb" title="Phonetic">KK</span></span> 
</div> 
<ul> 
<li class="dct-ec"
               > 
<div  class="dct-ec"> 
<span class="dct-elb" title="Part-of-Speech">verb</span> 
</div> 
<ul> 
<li class="dct-em"
               > 
<div  class="dct-em"> 
<span class="dct-tt">to leave somebody, especially somebody you are responsible for, with no intention of returning</span> <span class="dct-tt">(不顾责任、义务等)离弃,遗弃,抛弃
<span class="dct-tlb" title="Complement">~ sb (to sth)</span> 
<span class="dct-tlb" title="Grammar">VN</span></span> 
</div> 
<ul> 
<li class="dct-ee"
              style="display:none" mce_style="display:none" > 
<div  class="dct-ee"> 
<span class="dct-tt">The baby had been abandoned by its mother.</span> <span class="dct-tt">这个婴儿被母亲遗弃了。</span> 
</div> 
</li> 
<li class="dct-ee"
              style="display:none" mce_style="display:none" > 
<div  class="dct-ee"> 
<span class="dct-tt">People often simply abandon their pets when they go abroad.</span> <span class="dct-tt">人们出国时常常丢下宠物不管,一走了之。</span> 
</div> 
</li> 
<li class="dct-ee"
              style="display:none" mce_style="display:none" > 
<div  class="dct-ee"> 
<span class="dct-tt">The study showed a deep fear among the elderly of being abandoned to the care of strangers.</span> <span class="dct-tt">研究表明,老人十分害怕被丢给陌生人照管。</span> 
</div> 
</li> 
</ul> 
</li> 
<li class="dct-em"
               > 
<div  class="dct-em"> 
<span class="dct-tt">to leave a thing or place, especially because it is impossible or dangerous to stay</span> <span class="dct-tt">不得已而放弃;舍弃
<span class="dct-tlb" title="Complement">~ sth (to sb/sth)</span> 
<span class="dct-tlb" title="Grammar">VN</span></span> 
</div> 
<ul> 
<li class="dct-ee"
              style="display:none" mce_style="display:none" > 
<div  class="dct-ee"> 
<span class="dct-tt">Snow forced many drivers to abandon their vehicles.</span> <span class="dct-tt">大雪迫使许多驾驶者弃车步行。</span> 
</div> 
</li> 
<li class="dct-ee"
              style="display:none" mce_style="display:none" > 
<div  class="dct-ee"> 
<span class="dct-tt">They had to abandon their lands and property to the invading forces.</span> <span class="dct-tt">他们不得不放弃土地和财产,让侵略军占领。</span> 
</div> 
</li> 
<li class="dct-ee"
              style="display:none" mce_style="display:none" > 
<div  class="dct-ee"> 
<span class="dct-tt">He gave the order to abandon ship(= to leave the ship because it was sinking).</span> <span class="dct-tt">他下令弃船(因船快要沉没)。</span> 
</div> 
</li> 
</ul> 
</li> 
<li class="dct-em"
               > 
<div  class="dct-em"> 
<span class="dct-tt">to stop supporting or helping somebody; to stop believing in something</span> <span class="dct-tt">停止(支持或帮助);放弃(信念)
<span class="dct-tlb" title="Grammar">VN</span></span> 
</div> 
<ul> 
<li class="dct-ee"
              style="display:none" mce_style="display:none" > 
<div  class="dct-ee"> 
<span class="dct-tt">The country abandoned its political leaders after the war.</span> <span class="dct-tt">战后该国人民不再拥护他们的政治领袖。</span> 
</div> 
</li> 
<li class="dct-ee"
              style="display:none" mce_style="display:none" > 
<div  class="dct-ee"> 
<span class="dct-tt">By 1930 he had abandoned his Marxist principles.</span> <span class="dct-tt">1930 年时他已放弃了马克思主义信念。</span> 
</div> 
</li> 
</ul> 
</li> 
<li class="dct-em"
               > 
<div  class="dct-em"> 
<span class="dct-tt">to stop doing something, especially before it is finished; to stop having something</span> <span class="dct-tt">中止;放弃;不再有
<span class="dct-tlb" title="Grammar">VN</span></span> 
</div> 
<ul> 
<li class="dct-ee"
              style="display:none" mce_style="display:none" > 
<div  class="dct-ee"> 
<span class="dct-tt">They had to abandon the match because of rain.</span> <span class="dct-tt">因为下雨,他们只好中止比赛。</span> 
</div> 
</li> 
<li class="dct-ee"
              style="display:none" mce_style="display:none" > 
<div  class="dct-ee"> 
<span class="dct-tt">I have abandoned hope of any reconciliation.</span> <span class="dct-tt">我已对任何和解都不再抱希望。</span> 
</div> 
</li> 
</ul> 
</li> 
<li class="dct-em"
               > 
<div  class="dct-em"> 
<span class="dct-tt">to feel an emotion so strongly that you can feel nothing else</span> <span class="dct-tt">陷入,沉湎于(某种情感)
<span class="dct-tlb" title="Complement">~ yourself to sth</span> 
<span class="dct-tlb" title="Register">literary</span> 
<span class="dct-tlb" title="Grammar">VN</span></span> 
</div> 
<ul> 
<li class="dct-ee"
              style="display:none" mce_style="display:none" > 
<div  class="dct-ee"> 
<span class="dct-tt">He abandoned himself to despair.</span> <span class="dct-tt">他陷入绝望。</span> 
</div> 
</li> 
</ul> 
</li> 
</ul> 
</li> 
<li class="dct-ec"
               > 
<div  class="dct-ec"> 
<span class="dct-elb" title="Part-of-Speech">noun</span> 
</div> 
<ul> 
<li class="dct-em"
               > 
<div  class="dct-em"> 
<span class="dct-tt">an uncontrolled way of behaving that shows that somebody does not care what other people think</span> <span class="dct-tt">放任;放纵
<span class="dct-tlb" title="Grammar">uncountable</span> 
<span class="dct-tlb" title="Register">written</span></span> 
</div> 
<ul> 
<li class="dct-ee"
              style="display:none" mce_style="display:none" > 
<div  class="dct-ee"> 
<span class="dct-tt">He signed cheques with careless abandon.</span> <span class="dct-tt">他无所顾忌地乱开支票。</span> 
</div> 
</li> 
</ul> 
<ul> 
<li class="dct-er"
               > 
<div  class="dct-er"> 
<span class="dct-elb" title="Word">See also:</span> 
</div> 
<div  class="dct-er"> 
<span class="dct-tt"> 
<a href="/dictionary?hl=en&q=with+gay+abandon&sl=en&tl=zh-CN&oi=dict_lk" mce_href="dictionary?hl=en&q=with+gay+abandon&sl=en&tl=zh-CN&oi=dict_lk">with gay abandon</a></span> 
</div> 
</li> 
</ul> 
</li> 
</ul> 
</li> 
</ul> 
</li> 
</ul> 
<h3>English dictionary</h3> 
<ul class="dct-e2"  > 
<li class="dct-eh"
             > 
<div  class="dct-eh"> 
<span class="dct-tt">a·ban·don</span> 
</div> 
<ul> 
<li class="dct-em"
               > 
<div  class="dct-em"> 
<span class="dct-tt">Complete lack of inhibition or restraint</span> 
</div> 
</li> 
</ul> 
</li> 
</ul> 
<div class="mr-wds"> 
<a href="/dictionary?hl=en&q=abandon&sl=en&tl=en&oi=dict_mo" mce_href="dictionary?hl=en&q=abandon&sl=en&tl=en&oi=dict_mo"> 
More English dictionary results »</a> 
</div> 
<h3>Related phrases</h3> 
<ul class="rlt-snt"> 
<li> 
<div> 
<b><a href=" 
  /dictionary?q=abandon+oneself+to&hl=en&sl=en&tl=zh-CN&oi=dict_re
" mce_href=" 
  /dictionary?q=abandon+oneself+to&hl=en&sl=en&tl=zh-CN&oi=dict_re
">abandon oneself to</a></b> 
</div> 
沉溺于
</li> 
<li> 
<div> 
<b><a href=" 
  /dictionary?q=with+gay+abandon&hl=en&sl=en&tl=zh-CN&oi=dict_re
" mce_href=" 
  /dictionary?q=with+gay+abandon&hl=en&sl=en&tl=zh-CN&oi=dict_re
">with gay abandon</a></b> 
</div> 
不考虑后果;轻率
</li> 
</ul> 
<h3>Related languages</h3> 
<ul> 
<li> 
<strong>abandon</strong> is also a word in:
<a href="/dictionary?q=abandon&hl=en&sl=fr&tl=en
" mce_href="dictionary?q=abandon&hl=en&sl=fr&tl=en
">français</a> 
</li> 
</ul> 
<h3>Synonyms</h3> 
<ul> 
<li> 
<span class="dct-elb" title="Part-of-speech">verb</span>:<span class="dct-tt"> 
<a href="/dictionary?hl=en&q=leave&sl=en&tl=zh-CN&oi=dict_lk" mce_href="dictionary?hl=en&q=leave&sl=en&tl=zh-CN&oi=dict_lk">leave</a></span>,<span class="dct-tt"> 
<a href="/dictionary?hl=en&q=relinquish&sl=en&tl=zh-CN&oi=dict_lk" mce_href="dictionary?hl=en&q=relinquish&sl=en&tl=zh-CN&oi=dict_lk">relinquish</a></span>,<span class="dct-tt"> 
<a href="/dictionary?hl=en&q=forsake&sl=en&tl=zh-CN&oi=dict_lk" mce_href="dictionary?hl=en&q=forsake&sl=en&tl=zh-CN&oi=dict_lk">forsake</a></span>,<span class="dct-tt"> 
<a href="/dictionary?hl=en&q=quit&sl=en&tl=zh-CN&oi=dict_lk" mce_href="dictionary?hl=en&q=quit&sl=en&tl=zh-CN&oi=dict_lk">quit</a></span>,<span class="dct-tt"> 
<a href="/dictionary?hl=en&q=give+up&sl=en&tl=zh-CN&oi=dict_lk" mce_href="dictionary?hl=en&q=give+up&sl=en&tl=zh-CN&oi=dict_lk">give up</a></span>,<span class="dct-tt"> 
<a href="/dictionary?hl=en&q=desert&sl=en&tl=zh-CN&oi=dict_lk" mce_href="dictionary?hl=en&q=desert&sl=en&tl=zh-CN&oi=dict_lk">desert</a></span>,<span class="dct-tt"> 
<a href="/dictionary?hl=en&q=renounce&sl=en&tl=zh-CN&oi=dict_lk" mce_href="dictionary?hl=en&q=renounce&sl=en&tl=zh-CN&oi=dict_lk">renounce</a></span>,<span class="dct-tt"> 
<a href="/dictionary?hl=en&q=drop&sl=en&tl=zh-CN&oi=dict_lk" mce_href="dictionary?hl=en&q=drop&sl=en&tl=zh-CN&oi=dict_lk">drop</a></span>,<span class="dct-tt"> 
<a href="/dictionary?hl=en&q=vacate&sl=en&tl=zh-CN&oi=dict_lk" mce_href="dictionary?hl=en&q=vacate&sl=en&tl=zh-CN&oi=dict_lk">vacate</a></span> 
</li> 
</ul> 
<h3>Web translations</h3> 
<div> 
<h2 class="wd">abandon</h2> 
<div class="wbtr_cnt"> 
<ol> 
<li> 
<span class="wbtr_mn">放弃</span> 
<span class="wbtr_snp"><b>abandon放弃</b>离弃遗弃They were accused of abandoning their own principles </span> 
<span class="wbtr_url"> 
<a href="http://www.google.com/url?q=http://i.eol.cn/gchat.php%3Fid%3D5402&source=dictionary&type=we&usg=AFQjCNFpn25cb8sXwZ7B4vxhy9Rzg2Q33Q" mce_href="http://www.google.com/url?q=http://i.eol.cn/gchat.php%3Fid%3D5402&source=dictionary&type=we&usg=AFQjCNFpn25cb8sXwZ7B4vxhy9Rzg2Q33Q" target="_blank">i.eol.cn</a> 
</span> -
<span class="wbtr_rs"> 
<a href="http://www.google.com/search?hl=en&q=%22abandon%22+%22%E6%94%BE%E5%BC%83%22&ie=UTF-8&oi=dict_we" mce_href="http://www.google.com/search?hl=en&q=%22abandon%22+%22%E6%94%BE%E5%BC%83%22&ie=UTF-8&oi=dict_we" target="_blank"> 
Related search
</a> 
</span> 
</li> 
<li> 
<span class="wbtr_mn">抛弃</span> 
<span class="wbtr_snp"><b>抛弃</b>放弃 <b>abandon</b> 阿巴诺喹 Abanoquil 减轻减少消除 abate. 在线英语学习. 阿贝氏</span> 
<span class="wbtr_url"> 
<a href="http://www.google.com/url?q=http://www.scientrans.com/vocabulary/pages/20080202134324_34_65_1.html&source=dictionary&type=we&usg=AFQjCNHP7exeD0Iw8ck0Ps1yqu1yyu52SQ" mce_href="http://www.google.com/url?q=http://www.scientrans.com/vocabulary/pages/20080202134324_34_65_1.html&source=dictionary&type=we&usg=AFQjCNHP7exeD0Iw8ck0Ps1yqu1yyu52SQ" target="_blank">www.scientrans.com</a> 
</span> -
<span class="wbtr_rs"> 
<a href="http://www.google.com/search?hl=en&q=%22abandon%22+%22%E6%8A%9B%E5%BC%83%22&ie=UTF-8&oi=dict_we" mce_href="http://www.google.com/search?hl=en&q=%22abandon%22+%22%E6%8A%9B%E5%BC%83%22&ie=UTF-8&oi=dict_we" target="_blank"> 
Related search
</a> 
</span> 
</li> 
<li> 
<span class="wbtr_mn">遗弃</span> 
<span class="wbtr_snp"><b>abandon</b>放弃离弃<b>遗弃</b>They were accused of abandoning their own principles </span> 
<span class="wbtr_url"> 
<a href="http://www.google.com/url?q=http://i.eol.cn/gchat.php%3Fid%3D5402&source=dictionary&type=we&usg=AFQjCNFpn25cb8sXwZ7B4vxhy9Rzg2Q33Q" mce_href="http://www.google.com/url?q=http://i.eol.cn/gchat.php%3Fid%3D5402&source=dictionary&type=we&usg=AFQjCNFpn25cb8sXwZ7B4vxhy9Rzg2Q33Q" target="_blank">i.eol.cn</a> 
</span> -
<span class="wbtr_rs"> 
<a href="http://www.google.com/search?hl=en&q=%22abandon%22+%22%E9%81%97%E5%BC%83%22&ie=UTF-8&oi=dict_we" mce_href="http://www.google.com/search?hl=en&q=%22abandon%22+%22%E9%81%97%E5%BC%83%22&ie=UTF-8&oi=dict_we" target="_blank"> 
Related search
</a> 
</span> 
</li> 
<li> 
<span class="wbtr_mn">舍弃</span> 
<span class="wbtr_snp"><b>舍弃 abandon</b> 缩写地址呼号 abbreviated address calling 异常终止倾印 abend dump </span> 
<span class="wbtr_url"> 
<a href="http://www.google.com/url?q=http://www.scientrans.com/vocabulary/pages/20080317172247_106_65_1.html&source=dictionary&type=we&usg=AFQjCNExbMe6li2ZJzqgDvGM23Qdt1smpw" mce_href="http://www.google.com/url?q=http://www.scientrans.com/vocabulary/pages/20080317172247_106_65_1.html&source=dictionary&type=we&usg=AFQjCNExbMe6li2ZJzqgDvGM23Qdt1smpw" target="_blank">www.scientrans.com</a> 
</span> -
<span class="wbtr_rs"> 
<a href="http://www.google.com/search?hl=en&q=%22abandon%22+%22%E8%88%8D%E5%BC%83%22&ie=UTF-8&oi=dict_we" mce_href="http://www.google.com/search?hl=en&q=%22abandon%22+%22%E8%88%8D%E5%BC%83%22&ie=UTF-8&oi=dict_we" target="_blank"> 
Related search
</a> 
</span> 
</li> 
<li> 
<span class="wbtr_mn">丢弃</span> 
<span class="wbtr_snp"><b>abandon</b> vt<b>丢弃</b>放弃抛弃 ability n能力能耐本领 able a有能力的出色的 abnormal a不</span> 
<span class="wbtr_url"> 
<a href="http://www.google.com/url?q=http://www.51jnjj.cn/news_info.asp%3Fid%3D1602&source=dictionary&type=we&usg=AFQjCNGk60J0xWH-ue-l_HZKfm3O1PNfgQ" mce_href="http://www.google.com/url?q=http://www.51jnjj.cn/news_info.asp%3Fid%3D1602&source=dictionary&type=we&usg=AFQjCNGk60J0xWH-ue-l_HZKfm3O1PNfgQ" target="_blank">www.51jnjj.cn</a> 
</span> -
<span class="wbtr_rs"> 
<a href="http://www.google.com/search?hl=en&q=%22abandon%22+%22%E4%B8%A2%E5%BC%83%22&ie=UTF-8&oi=dict_we" mce_href="http://www.google.com/search?hl=en&q=%22abandon%22+%22%E4%B8%A2%E5%BC%83%22&ie=UTF-8&oi=dict_we" target="_blank"> 
Related search
</a> 
</span> 
</li> 
</ol> 
</div> 
</div> 
<h3>Usage examples</h3> 
<ul class="rlt-snt"> 
<li><div>"People died for this tournament, others were injured. We can't <b>abandon</b> them and leave like cowards," Alaixys Romao told French sports agency L'Equipe. "If we stay here, it's for them. But also so as not to give satisfaction to the rebels....</div><div><span class="grey">Jan 10, 2010</span> - <span> 
<a class="lightblue" href="http://www.google.com/url?q=http://en.wikipedia.org/wiki/Alaixys_Romao&source=dictionary&usg=AFQjCNG0zCsZW1KyoHGeZnumG5E2-qMhSg" mce_href="http://www.google.com/url?q=http://en.wikipedia.org/wiki/Alaixys_Romao&source=dictionary&usg=AFQjCNG0zCsZW1KyoHGeZnumG5E2-qMhSg">Alaixys Romao</a></span> - <span> 
<a class="green" href="http://www.google.com/url?q=http://www.bbc.co.uk/blogs/piersedwards/2010/01/gun_attack_overshadows_africa.html&source=dictionary&usg=AFQjCNFXePJzwrZ-RG_9bgFB4QdVuCMbhg" mce_href="http://www.google.com/url?q=http://www.bbc.co.uk/blogs/piersedwards/2010/01/gun_attack_overshadows_africa.html&source=dictionary&usg=AFQjCNFXePJzwrZ-RG_9bgFB4QdVuCMbhg">BBC Sport (blog)</a></span></div></li> 
<li><div>"The president would have us believe there are two choices: keep all of our troops in Iraq or <b>abandon</b> these Iraqis," Obama said. "I reject this choice."</div><div><span class="grey">Sep 12, 2007</span> - <span> 
<a class="lightblue" href="http://www.google.com/url?q=http://en.wikipedia.org/wiki/Barack_Obama&source=dictionary&usg=AFQjCNHQ0yfPaaXFGqLKymRgcres0I2nuA" mce_href="http://www.google.com/url?q=http://en.wikipedia.org/wiki/Barack_Obama&source=dictionary&usg=AFQjCNHQ0yfPaaXFGqLKymRgcres0I2nuA">Barack Obama</a></span> - <span> 
<a class="green" href="http://www.google.com/url?q=http://www.forbes.com/feeds/ap/2007/09/12/ap4108235.html&source=dictionary&usg=AFQjCNE9DqEquDtHBRoJSv9cfvjUPrgevg" mce_href="http://www.google.com/url?q=http://www.forbes.com/feeds/ap/2007/09/12/ap4108235.html&source=dictionary&usg=AFQjCNE9DqEquDtHBRoJSv9cfvjUPrgevg">Forbes</a></span></div></li> 
<li><div>"I am deeply disappointed that the governor has decided to <b>abandon</b> the state and her constituents before her term has concluded," Murkowski said.</div><div><span class="grey">Jul 3, 2009</span> - <span> 
<a class="lightblue" href="http://www.google.com/url?q=http://en.wikipedia.org/wiki/Lisa_Murkowski&source=dictionary&usg=AFQjCNGfUU0pjzbEuDwnY81jySj6rKn9pA" mce_href="http://www.google.com/url?q=http://en.wikipedia.org/wiki/Lisa_Murkowski&source=dictionary&usg=AFQjCNGfUU0pjzbEuDwnY81jySj6rKn9pA">Lisa Murkowski</a></span> - <span> 
<a class="green" href="http://www.google.com/url?q=http://www.politico.com/blogs/bensmith/0709/L_Murkowski_Deeply_disappointed_Palin_has_decided_to_abandon_the_state_.html&source=dictionary&usg=AFQjCNGtnwsoPi3e6Y5XTizOkg87g-_AsQ" mce_href="http://www.google.com/url?q=http://www.politico.com/blogs/bensmith/0709/L_Murkowski_Deeply_disappointed_Palin_has_decided_to_abandon_the_state_.html&source=dictionary&usg=AFQjCNGtnwsoPi3e6Y5XTizOkg87g-_AsQ">Politico</a></span></div></li> 
</ul> 
<h3>Web definitions</h3> 
<ul class="gls"> 
<li> 
<ul> 
<li> 
forsake, leave behind; "We abandoned the old car in the empty parking lot" <br> 
</li> 
<div> 
<a href="http://www.google.com/url?q=http://wordnetweb.princeton.edu/perl/webwn%3Fs%3Dabandon&source=dictionary&type=de&usg=AFQjCNHqLML70dHqzi04RiOEhnZ9Jvl71g" mce_href="http://www.google.com/url?q=http://wordnetweb.princeton.edu/perl/webwn%3Fs%3Dabandon&source=dictionary&type=de&usg=AFQjCNHqLML70dHqzi04RiOEhnZ9Jvl71g"> 
wordnetweb.princeton.edu/perl/webwn
</a> 
</div> 
</ul> 
</li> 
<li> 
<ul> 
<li> 
give up with the intent of never claiming again; "Abandon your life to God"; "She gave up her children to her ex-husband when she moved to Tahiti"; "We gave the drowning victim up for dead" <br> 
</li> 
<div> 
<a href="http://www.google.com/url?q=http://wordnetweb.princeton.edu/perl/webwn%3Fs%3Dabandon&source=dictionary&type=de&usg=AFQjCNHqLML70dHqzi04RiOEhnZ9Jvl71g" mce_href="http://www.google.com/url?q=http://wordnetweb.princeton.edu/perl/webwn%3Fs%3Dabandon&source=dictionary&type=de&usg=AFQjCNHqLML70dHqzi04RiOEhnZ9Jvl71g"> 
wordnetweb.princeton.edu/perl/webwn
</a> 
</div> 
</ul> 
</li> 
<li> 
<ul> 
<li> 
vacate: leave behind empty; move out of; "You must vacate your office by tonight" <br> 
</li> 
<div> 
<a href="http://www.google.com/url?q=http://wordnetweb.princeton.edu/perl/webwn%3Fs%3Dabandon&source=dictionary&type=de&usg=AFQjCNHqLML70dHqzi04RiOEhnZ9Jvl71g" mce_href="http://www.google.com/url?q=http://wordnetweb.princeton.edu/perl/webwn%3Fs%3Dabandon&source=dictionary&type=de&usg=AFQjCNHqLML70dHqzi04RiOEhnZ9Jvl71g"> 
wordnetweb.princeton.edu/perl/webwn
</a> 
</div> 
</ul> 
</li> 
</ul> 
<div class="mr-wds"> 
<a href="/dictionary?hl=en&q=abandon&sl=en&tl=en" mce_href="dictionary?hl=en&q=abandon&sl=en&tl=en"> 
Show more Web definitions »</a> 
</div> 
</div> 
</div> 
<div class="dct-rt-sct"> 
<div class="wl-hd"> 
<img src="/dictionary/image/starred.png" mce_src="dictionary/image/starred.png"> 
<a href="/dictionary/wordlist?hl=en" mce_href="dictionary/wordlist?hl=en">Starred words »</a> 
</div> 
<div id="dict-hist" class="rt-sct-blk"> 
<h4>Recent searches</h4> 
<div> 
<ul> 
<li> 
<a href="/dictionary?hl=en&sl=en&tl=en&q=abeyance" mce_href="dictionary?hl=en&sl=en&tl=en&q=abeyance">abeyance</a> 
</li> 
<li> 
<a href="/dictionary?hl=en&sl=en&tl=zh-CN&q=abeyance" mce_href="dictionary?hl=en&sl=en&tl=zh-CN&q=abeyance">abeyance</a> 
</li> 
<li> 
<a href="/dictionary?hl=en&sl=en&tl=zh-CN&q=abandon" mce_href="dictionary?hl=en&sl=en&tl=zh-CN&q=abandon">abandon</a> 
</li> 
<li> 
<a href="/dictionary?hl=en&sl=en&tl=zh-CN&q=abet" mce_href="dictionary?hl=en&sl=en&tl=zh-CN&q=abet">abet</a> 
</li> 
<li> 
<a href="/dictionary?hl=en&sl=en&tl=zh-CN&q=Phonetic" mce_href="dictionary?hl=en&sl=en&tl=zh-CN&q=Phonetic">Phonetic</a> 
</li> 
</ul> 
<div class="mrhist"> 
<a href="http://www.google.com/history/lookup?hl=en&st=dict" mce_href="http://www.google.com/history/lookup?hl=en&st=dict"> 
All recent searches »</a> 
</div> 
</div> 
</div> 
</div> 
<br class="clear"> 
</div> 
<div class="dscl-dct"><p> 
Results partly provided by <a href="http://www.dreye.com.cn" mce_href="http://www.dreye.com.cn">Dr.eye</a>.
</p></div> 
<div class="dscl-glb"> 
The usage examples, images and web definitions on this page were selected automatically by a computer program. They do not necessarily reflect the views of Google Inc. or its employees.
</div> 
<center> 
<p/> 
<hr class="z"> 
<div class="" style="border-top: 1px solid rgb(204, 204, 240); padding: 15px 2px 2px;" mce_style="border-top: 1px solid #ccccf0; padding: 15px 2px 2px;"> 
<font size="-1"> 
<span >©2009 Google</span> 
-
<a href="http://www.google.com/webhp?hl=en" mce_href="http://www.google.com/webhp?hl=en">Google Home</a> 
-
<a href="http://www.google.com/intl/en/about.html" mce_href="http://www.google.com/intl/en/about.html">All About Google</a> 
</font> 
</div> 
</center> 
</div> 
</body> 
<mce:script type="text/javascript"><!--
 
(function() {
})();
if (!window.google) { window.google = {}; }
(function(){if(window.jstiming){window.jstiming.a={};window.jstiming.c=1;var j=function(a,c,e){var b=a.t[c],g=a.t.start;if(b&&(g||e)){b=a.t[c][0];g=e!=undefined?e:g[0];return b-g}},n=function(a,c,e){var b="";if(window.jstiming.pt){b+="&srt="+window.jstiming.pt;delete window.jstiming.pt}try{if(window.external&&window.external.tran)b+="&tran="+window.external.tran;else if(window.gtbExternal&&window.gtbExternal.tran)b+="&tran="+window.gtbExternal.tran();else if(window.chrome&&window.chrome.csi)b+="&tran="+window.chrome.csi().tran}catch(g){}var d=
window.chrome;if(d)if(d=d.loadTimes){if(d().wasFetchedViaSpdy)b+="&p=s";if(d().wasNpnNegotiated)b+="&npn=1";if(d().wasAlternateProtocolAvailable)b+="&apa=1"}if(a.b)b+="&"+a.b;d=a.t;var m=d.start,k=[],h=[];for(var f in d)if(f!="start")if(f.indexOf("_")!=0){var i=d[f][1];if(i)d[i]&&h.push(f+"."+j(a,f,d[i][0]));else m&&k.push(f+"."+j(a,f))}delete d.start;if(c)for(var l in c)b+="&"+l+"="+c[l];return a=[e?e:"http://csi.gstatic.com/csi","?v=3","&s="+(window.jstiming.sn||"dictionary")+"&action=",a.name,
h.length?"&it="+h.join(","):"","",b,"&rt=",k.join(",")].join("")};window.jstiming.report=function(a,c,e){a=n(a,c,e);if(!a)return"";c=new Image;var b=window.jstiming.c++;window.jstiming.a[b]=c;c.onload=c.onerror=function(){delete window.jstiming.a[b]};c.src=a;c=null;return a}};})();
(function(){var b=true,g=null,h=h||{};h.global=this;h.v=b;h.w="en";h.d=g;h.Z=function(a){h.g(a)};h.g=function(a,c,d){a=a.split(".");d=d||h.global;!(a[0]in d)&&d.execScript&&d.execScript("var "+a[0]);for(var e;a.length&&(e=a.shift());)if(!a.length&&h.p(c))d[e]=c;else d=d[e]?d[e]:d[e]={}};h.K=function(a,c){for(var d=a.split("."),e=c||h.global,f;f=d.shift();)if(e[f])e=e[f];else return g;return e};h.M=function(a,c){var d=c||h.global;for(var e in a)d[e]=a[e]};h.A=function(){};h.da=false;h.aa=function(){};h.D="";
h.X=function(){};h.N=function(){return arguments[0]};h.z=function(){throw Error("unimplemented abstract method");};h.B=function(a){a.I=function(){return a.o||(a.o=new a)}};
h.a=function(a){var c=typeof a;if(c=="object")if(a){if(a instanceof Array||!(a instanceof Object)&&Object.prototype.toString.call(a)=="[object Array]"||typeof a.length=="number"&&typeof a.splice!="undefined"&&typeof a.propertyIsEnumerable!="undefined"&&!a.propertyIsEnumerable("splice"))return"array";if(!(a instanceof Object)&&(Object.prototype.toString.call(a)=="[object Function]"||typeof a.call!="undefined"&&typeof a.propertyIsEnumerable!="undefined"&&!a.propertyIsEnumerable("call")))return"function"}else return"null";
else if(c=="function"&&typeof a.call=="undefined")return"object";return c};h.s=function(a,c){if(c in a)for(var d in a)if(d==c&&Object.prototype.hasOwnProperty.call(a,c))return b;return false};h.Y=function(a,c){return a instanceof Object?Object.prototype.propertyIsEnumerable.call(a,c):h.s(a,c)};h.p=function(a){return a!==undefined};h.U=function(a){return a===g};h.S=function(a){return a!=g};h.O=function(a){return h.a(a)=="array"};
h.P=function(a){var c=h.a(a);return c=="array"||c=="object"&&typeof a.length=="number"};h.R=function(a){return h.q(a)&&typeof a.getFullYear=="function"};h.W=function(a){return typeof a=="string"};h.Q=function(a){return typeof a=="boolean"};h.V=function(a){return typeof a=="number"};h.T=function(a){return h.a(a)=="function"};h.q=function(a){a=h.a(a);return a=="object"||a=="array"||a=="function"};h.n=function(a){return a[h.b]||(a[h.b]=++h.u)};
h.t=function(a){"removeAttribute"in a&&a.removeAttribute(h.b);try{delete a[h.b]}catch(c){}};h.b="closure_uid_"+Math.floor(Math.random()*2147483648).toString(36);h.u=0;h.H=h.n;h.$=h.t;h.l=function(a){var c=h.a(a);if(c=="object"||c=="array"){if(a.k)return a.k();c=c=="array"?[]:{};for(var d in a)c[d]=h.l(a[d]);return c}return a};
h.c=function(a,c){var d=c||h.global;if(arguments.length>2){var e=Array.prototype.slice.call(arguments,2);return function(){var f=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(f,e);return a.apply(d,f)}}else return function(){return a.apply(d,arguments)}};h.r=function(a){var c=Array.prototype.slice.call(arguments,1);return function(){var d=Array.prototype.slice.call(arguments);d.unshift.apply(d,c);return a.apply(this,d)}};h.i=function(a,c){for(var d in c)a[d]=c[d]};
h.now=Date.now||function(){return+new Date};
h.L=function(a){if(h.global.execScript)h.global.execScript(a,"JavaScript");else if(h.global.eval){if(h.d==g){h.global.eval("var _et_ = 1;");if(typeof h.global._et_!="undefined"){delete h.global._et_;h.d=b}else h.d=false}if(h.d)h.global.eval(a);else{var c=h.global.document,d=c.createElement("script");d.type="text/javascript";d.defer=false;d.appendChild(c.createTextNode(a));c.body.appendChild(d);c.body.removeChild(d)}}else throw Error("goog.globalEval not available");};h.ca=b;
h.G=function(a,c){var d=a+(c?"-"+c:"");return h.f&&d in h.f?h.f[d]:d};h.ba=function(a){h.f=a};h.J=function(a,c){var d=c||{};for(var e in d){var f=(""+d[e]).replace(//$/g,"$$");a=a.replace(RegExp("//{//$"+e+"//}","gi"),f)}return a};h.m=function(a,c,d){h.g(a,c,d)};h.F=function(a,c,d){a[c]=d};h.h=function(a,c){function d(){}d.prototype=c.prototype;a.e=c.prototype;a.prototype=new d;a.prototype.constructor=a};
h.C=function(a,c){var d=arguments.callee.caller;if(d.e)return d.e.constructor.apply(a,Array.prototype.slice.call(arguments,1));for(var e=Array.prototype.slice.call(arguments,2),f=false,i=a.constructor;i;i=i.e&&i.e.constructor)if(i.prototype[c]===d)f=b;else if(f)return i.prototype[c].apply(a,e);if(a[c]===d)return a.constructor.prototype[c].apply(a,e);else throw Error("goog.base called from a method of one name to a method of a different name");};h.scope=function(a){a.call(h.global)};h.j=b;
if(h.j){Function.prototype.c=function(a){if(arguments.length>1){var c=Array.prototype.slice.call(arguments,1);c.unshift(this,a);return h.c.apply(g,c)}else return h.c(this,a)};Function.prototype.r=function(){var a=Array.prototype.slice.call(arguments);a.unshift(this,g);return h.c.apply(g,a)};Function.prototype.h=function(a){h.h(this,a)};Function.prototype.i=function(a){h.i(this.prototype,a)}};function j(){var a=window.jstiming.load;a.tick("ol");window.jstiming.report(a)}h.m("tickBodyLoadAndReport",j);})();
var installFunctions = function() {
window.google.ac.install(document.f,document.f.q,"d",true,
"close",true,"","","");
onUpdateLangpair(document.f['dct-slc']);
};
var hideShowEl = document.getElementById('dct-clk-a');
if (hideShowEl) {
hideShowEl.href = 'javascript:google.toggleDictionaryExample()';
}
function onUpdateLangpair(sel) {
langpair = sel.options[sel.selectedIndex].value;
window.google.ac.update(langpair);
};
window.setTimeout(installFunctions, 10);
// --></mce:script> 
</html> 

注意到有一行信息:

<meta name="description" content="abandon : (不顾责任、义务等)离弃,遗弃,抛弃, 不得已而放弃;舍弃, 停止(支持或帮助);放弃(信念), 中止;放弃;不再有, 陷入,沉湎于(某种情感), 放任;放纵 - Google's free online dictionary service."> 

 

 包含单词abandon的中文释义。于是可以利用curl获取到Google Dictionary的翻译网页,然后直接在获取的网页中查找上面那一行信息。

 

#!/bin/bash
# Command line look up using Google's define feature - command line dictionary
# gd -i <input_file> -o <output_file> [-w <word>]
function query
{
	typeset wd=$1
	typeset TMPFILE=tmp.$wd
	typeset i=0
	while ((i<5))
	do
		curl -s -A 'Mozilla/4.0' "http://www.google.com/dictionary?langpair=zh-CN|en&hl=en&aq=f&q=$wd" >$TMPFILE 2>/dev/null
		if [ -s $TMPFILE ]; then
			break
		elif ((i=4)); then
			echo $wd >> failed.gd.$input
		fi
		((i=i+1))
		sleep 1
	done
	perl -i -p -e "print STDOUT /$1,/"/r/n/" if (m/($wd.*:.*)- Google.*/);" $TMPFILE
	rm -f $TMPFILE
}
##############################################
#	MAIN LINE START HERE
##############################################
typeset input=
typeset output=
typeset word=
typeset -i flag=0
while getopts 'i:o:w:' OPT
do
        case $OPT in
        i)	input=${OPTARG};;
        o)	output=${OPTARG};;
        w)	word=${OPTARG};flag=1;;
        *)      echo -u2 "ERROR: Invalid argument [$OPT]"
                ;;
        esac
done
shift `expr $OPTIND - 1`
if ((flag==0)); then
	perl -i.bk -p -e "s/^(/w+).*[/[//].*[/]//]//$1/;" $input # Eliminate the phonetic symbol
	WORDS=$(cat $input)
	for word in $WORDS
	do
		word_exp=$(query $word)
		if [ ${#word_exp} != 0 ]; then
			echo $word_exp >> $output
		else
			echo "$word:" >> $output
		fi
	done
else
	word_exp=$(query $word)
	if [ ${#word_exp} != 0 ]; then
		echo $word_exp
	else
		echo "$word:"
	fi
fi

 

2011-01-03 Update:

奉上完整版的程序:

#!/bin/bash
# Command line look up using Google's define feature - command line dictionary
# od [-b] [-g]-i <input_file> -o <output_file> [-w <word>]
# gd - Query words using Google Dictionary
function gd
{
	typeset wd=$1
	typeset TMPFILE=tmp.gd.$wd
	typeset -i i=0
	while ((i<5))
	do
		curl -s -A 'Mozilla/4.0' "http://www.google.com/dictionary?langpair=zh-CN|en&hl=en&aq=f&q=$wd" >$TMPFILE 2>/dev/null
		if [ -s $TMPFILE ]; then
			break
		elif ((i=4)); then
			echo $wd >> failed.gd.$input
		fi
		((i=i+1))
		sleep 1
	done
	perl -i -p -e "print STDOUT /$1,/"/r/n/" if (m/($wd.*:.*)- Google.*/);" $TMPFILE
	rm -f $TMPFILE
}
# bd - Query words using Baidu Dictionary
#
function bd
{
	typeset wd=$1
	typeset TMPFILE=tmp.bd.$wd
	typeset -i i=0
	while ((i<5))
	do
		curl -s -A 'Mozilla/4.0' "http://dict.baidu.com/s?tn=dict&wd="$word | html2text > $TMPFILE 2>/dev/null
		if [ -s $TMPFILE ]; then
			break
		elif ((i=4)); then
			echo $wd >> failed.bd.$input
		fi
		((i=i+1))
		sleep 1
	done
	./censor.pl $TMPFILE $wd
	rm -f $TMPFILE
}
##############################################
#	MAIN LINE START HERE
##############################################
typeset input=
typeset output=
typeset word=
typeset dict=z"gd bd"
typeset -i word_flag=0
while getopts 'agbi:o:w:' OPT
do
        case $OPT in
        g)	dict=gd;;
        b)	dict=bd;;
        i)	input=${OPTARG};;
        o)	output=${OPTARG};;
        w)	word=${OPTARG};word_flag=1;;
        *)      echo -u2 "ERROR: Invalid argument [$OPT]"
                ;;
        esac
done
shift `expr $OPTIND - 1`
if ((word_flag==0)); then
#	perl -i.bk -p -e "s/^(/w+).*[/[//].*[/]//]//$1/;" $input # Eliminate the phonetic symbols
	WORDS=$(cat $input)
	for word in $WORDS
	do
		case $dict in
		*bd*)	echo "------------------ $word -------------------" >> $output;;
		esac
		
		for d in $dict
		do
			word_exp=$($d $word)
			if [ ${#word_exp} != 0 ]; then
				echo $word_exp >> $output
			else
				echo "$word:" >> $output
			fi
		done
	done
else
	for d in $dict
	do
		$d $word
	done
fi

 

 

#!/usr/bin/perl -w
############### censor.pl #################
# Handle the explanations got from online dictionary.
# Inputs:
#	ARGV[0] -- temparory file containning the explanations
#	ARGV[1] -- keyword
############################################
use strict;
use Encode;
my $syntax = Encode::decode('utf8', '语法标注解释 ');
my $internet = Encode::decode('utf8', '以下结果来自互联网网络释义');
my $yingyin = Encode::decode('utf8', '英音');
my $meiyin = Encode::decode('utf8', '美音');
my $baidu = Encode::decode('utf8', '此内容系百度根据您的指令自动搜索的结果');
my $write_flag=0;
open(EXP,$ARGV[0]);
while (my $nextline=<EXP>) {
	chomp($nextline);
	$nextline = Encode::decode('utf8', $nextline);
	if ($nextline =~ m/.*$syntax.*/) {
		$write_flag=1;
		$nextline =~ s/$syntax//;
	} elsif ($nextline =~ m/.*$internet.*/ || $nextline =~ m/.*$baidu.*/) {
		$write_flag=0;
	}
			
	if ($write_flag eq 1) {
		if ($nextline !~ m/.*/*/*/*/*.*/) { # Excluse lines containning ****
			# Add a space between the keyword and 英音/美音
			$nextline =~ s/$ARGV[1]([$yingyin|$meiyin])/$ARGV[1] $1/; 
			print encode("utf8",$nextline),"/r/n"; # In perl, /r/n is needed to add a new line
		}
	}
}
close(EXP);

 

Linux Shared Memory的查看与设置

 

1. Linux Check Memory Usage

 

 

2. How to Check Shared Memory on Linux

 

3. Shared Memory Configuration

 

 

 

共享内存就是进程之间可以共享的一段内存,通过一个唯一的KEY值绑定
shmget()创建或获取
shmat()连接
shmdt()断连

共享内存的访问涉及同步措施,通常与信号灯一起使用
用ipcs -m命令可以查看系统中已有的共享内存段

/proc/sys/kernel/shm开头的几个文件是共享内存的参数


共享内存的访问涉及同步措施,通常与信号灯一起使用
用ipcs -m命令可以查看系统中已有的共享内存段

ipcs -m 看Shared Memory 共享内存

ipcs -q 看Message Queues 消息队列
ipcs -s 看Semaphore Arrays 信号量

 

使用命令:ipcs -al

------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 4091826
max total shared memory (pages) = 2097152
min seg size (bytes) = 1


1. Linux Check Memory Usage

by VIVEK GITE on APRIL 6, 2006 · 36 COMMENTS

How do I check used and free RAM memory usage under Linux operating systems using command line and GUI tools?

Linux comes with different set of commands to check memory usage. The free command displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel. The vmstat command reports information about processes, memory, paging, block IO, traps, and cpu activity. Finally, you can use the top command which provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel.

free command

Display free memory size in MB:

$ free -mOutput:

             total       used       free     shared    buffers     cached
Mem:           750        625        125          0         35        335
-/+ buffers/cache:        254        496
Swap:          956          0        956

Displays a line containing the totals memory in MB:
$ free -t -m

Output:

       total       used       free     shared    buffers     cached
Mem:           750        625        125          0         35        335
-/+ buffers/cache:        253        496
Swap:          956          0        956
Total:        1707        625       1082

vmstat command

Type vmstat command at shell prompt:

$ vmstat

Output:

procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa
1  0      0 131620  35432 341496    0    0    42    82  737  1364 15  3 81  1

top command

Type top command at the shell prompt:
$ top

Sample outputs:

Fig.01: top command displaying used memory

Fig.01: top command displaying used memory


To exit from top command type q key. Read man page of free, vmstat, top command for more information.

 

GNOME Desktop: GUI Tool

The Gnome System Monitor application enables you to display basic system information and monitor system processes, usage of system resources, and file systems. You can also use System Monitor to modify the behavior of your system. You can start System Monitor by visiting System menu > Choose Administration > System Monitor option. Or type the following command at the shell prompt:

 
gnome-system-monitor
 

Sample outputs:

Fig.02: Linux See Memory Usage With GUI System Monitor Tool

Fig.02: Linux See Memory Usage With GUI System Monitor Tool

 

----------------------------------------------------------------------------------------

2. How to Check Shared Memory on Linux

Shared memory is responsible for the smooth operation of your system; it acts as a space that multiple programs can access at once. This enables those programs to communicate in sync, while avoiding file redundancy. Shared memory can exist in the system's physical RAM or the swap file (which is virtual memory). In Linux operating systems, check the details of shared memory by typing in a few simple commands.

Difficulty: Moderately Easy

Instructions

  1. 1

    Power on your system and log in.

  2. 2

    Open a "Terminal" window.

  3. 3

    Type in "cat /proc/sys/kernel/shmall" and press "Enter." You'll see the total amount of shared memory available displayed in bytes. The max size of a shared memory segment is displayed with "cat /proc/sys/kernel/shmmax", and the total number of segments in the system is displayed with "cat /proc/sys/kernel/shmmni".

 

Read more: How to Check Shared Memory on Linux | eHow.com http://www.ehow.com/how_6849046_check-shared-memory-linux.html#ixzz19eUg5rtL

 

-------------------------------------------------------------------------------------------


3. Shared Memory Configuration

McIDAS-X 200x uses shared memory for a variety of tasks including frame allocation. By default, the shared memory facility is activated and should have sufficient maximum segment size on HP, IBM and SGI systems. However, this is not true for Sun systems running Solaris 2.x or Digital systems running True64. On Linux systems, the amount of available shared memory appears is equivalent to the combination of physical RAM and swap.

The system administrator should complete the steps below the first time McIDAS-X 200x is installed on Sun Solaris or Digital True64 workstations or if they desire to increase shared memory defaults on HP, IBM, or SGI systems.

Sun Solaris 2.X
SGI IRIX 6.x
HP HP-UX 10, 11
IBM AIX
Compaq Tru64 UNIX
RedHat Linux
FreeBSD 4.[789]
MacOS-X 7.4.0

 

Sun Solaris 2.x

The system administrator must complete the steps below the first time McIDAS-X is installed on a Sun workstation running Solaris 2. x .

  1.  

      Type: /usr/sbin/sysdef | grep SHMMAX

      
      536870912 max shared memory segment size (SHMMAX)
  2. 1. Force the kernel to activate the shared memory system at boot time by adding the line below to the appropriate location in the file 
    /etc/system .

    
    forceload: sys/shmsys

    2. Check the maximum size of a shared memory segment using the command below. The value is indicated in bytes; the example lists a 512 MB maximum shared memory segment.

    If your value is less than 512 MB, go to step 3. If your value is 512 MB or greater, go to step 4.

    3. Set the shared memory size to 512 MB by adding the line below to the appropriate location in the file /etc/system .

    
    set shmsys:shminfo_shmmax = 536870912

    4. Reboot the system so the forceload entry and 512 MB maximum shared memory size take effect.

SGI IRIX 6.x

On Irix, SHMMAX defaults to 512 MB (0x20000000 bytes), so tuning this parameter is unlikely to be needed. SHMMAX is found in /var/sysgen/mtune/shm.

HP HP-UX 10, 11

On HP-UX 10 and 11, the maximum value for SHMMAX is 1024 MB (0x40000000; the default value for 64 MB (0x04000000). SHMMAX is found in /etc/conf/master.d/core-hpux.

The procedure for changing the parameter is similar, if not identical, to the one described for HP-UX 9.

One way to check the current value of SHMMAX is to enter the following command:

Type: grep SHMMAX /etc/master

If the grep does not print anything, you are using the default value of 64 MB. If the grep prints something, the output might look like this:

 shmmax          SHMMAX              0X20000000 

The value is bytes, so here the maximum segment size has been set to 512 MB.

IBM AIX 4.x

The shmget(2) man page says that the maximum shared-memory segment size is 256 MB (0x10000000); this limit does not appear to be tunable.

Compaq Tru64 UNIX

The easiest way to increase shared-memory allocation on True64 is to use the GUI called dxkerneltuner, but one can also use the sysconfigdb command-line interface.

Running dxkerneltuner and increasing the shared-memory size to 64 MB will result in the following entry in the file /etc/sysconfigtab:


 ipc:
       shm-max=67108864

The following are the out-of-the-box defaults for the ipc subsystem for OSF/1 Version 4.0. They may be helpful for True64:

% sysconfig -q ipc
ipc:
msg-max = 8192
msg-mnb = 16384
msg-mni = 64
msg-tql = 40
shm-max = 4194304
shm-min = 1
shm-mni = 128
shm-seg = 32
sem-mni = 16
sem-msl = 25
sem-opm = 10
sem-ume = 10
sem-vmx = 32767
sem-aem = 16384
num-of-sems = 60
max-kernel-ports = 22487
port-hash-max-num = 1124350
port-reserved-max-num = 22487
set-max-num = 1029
ssm-threshold = 8388608
ssm-enable-core-dump = 1

 

 

RedHat Linux

There appears to be two ways of (re)defining the amount of shared memory in your system (tips thanks to Dave Glowacki of SSEC):

  • add this line to your /etc/rc.d/rc.local file:

    echo shared_memory_size > /proc/sys/kernel/shmmax

    (where shared_memory_size is the amount of shared memory you want to declare in bytes) and reboot.

    Note: since this will be the last thing run before your system comes up, your McIDAS session won't get a larger shared memory segment if it's started during the boot process).

     

  • a more permanent solution would be to change the value of SHMMAX in /usr/src/linux/include/asm/shmparam.h and rebuild your kernel

FreeBSD 4.[789]

Shared memory parameters are only read when the system goes from single user to multi user mode.

Add setting of shared memory max to /etc/sysctl.conf


# $FreeBSD: src/etc/sysctl.conf,v 1.1.2.3 2002/04/15 00:44:13 dougb Exp $
#
#  This file is read when going to multi-user and its contents piped thru
#  ``sysctl'' to adjust kernel values.  ``man 5 sysctl.conf'' for details.
#
kern.ipc.shmmax=536870912

and then reboot.

 

MacOS-X 7.4.0 (Panther)

In the Panther release of MacOS-X, shared memory is set in the file /etc/rc. The default settings will look something like:


# System tuning
sysctl -w kern.maxvnodes=$(echo $(sysctl -n hw.physmem) '33554432 / 512 * 1024 +p'|dc)
sysctl -w kern.sysv.shmmax=4194304
sysctl -w kern.sysv.shmmin=1
sysctl -w kern.sysv.shmmni=32
sysctl -w kern.sysv.shmseg=8
sysctl -w kern.sysv.shmall=1024

 

We recommend changing this to:


# System tuning
sysctl -w kern.maxvnodes=$(echo $(sysctl -n hw.physmem) '33554432 / 512 * 1024 +p'|dc)
sysctl -w kern.sysv.shmmax=536870912
sysctl -w kern.sysv.shmmin=1
sysctl -w kern.sysv.shmmni=4096
sysctl -w kern.sysv.shmseg=4096
sysctl -w kern.sysv.shmall=131072

 

After making these changes, the system will need to be rebooted for the changes to take effect.

 

Ksh的几点小技巧

  1. 在一个函数(function)中,如果不希望局部变量影响到全局变量或环境变量,可以用typeset来定义。
  2. 对于多个参数的函数或脚本,对多个输入参数的处理有两种办法:
  • 一是利用如下方式:

while (($# != 0)) 
do 
      # process $1 
      shift 
done 

 

  • 另一种方法是利用如下方式:

while getopts :A:B:c:d:e:E:C:i:G:L:M:R:hD:V OPT; do
	case $OPT in
	A)	export E_CONFIG=${OPTARG}
		;;
	B)	Banner=$(echo "$OPTARG" | tr '%' ' ');;
	C)	Mach="-m $OPTARG"; MachName=$OPTARG;;
	D)	DBDir=$OPTARG;;
	G)	TRCellGen=$OPTARG;;
	i)	iconic='-iconic';;
	L)  Lab3BEM=$OPTARG;;
	M)  NumMobileSub=$OPTARG;;
	esac
done
shift OPTIND-1

 

Notes of Introduction to OS Abstractions Using Plan 9 from Bell Labs(I)

 

1. Loaded Programs

1.1 Command nm

Command nm can be used to display symbol information in both objects and binary files, because it looks at the symbol table stored in the binary for debugging purposes. Command strip can be used to remove the symbol table.

 

Option –n asks nm to sort the output by symbol address. The addresses are virtual memory addresses, because the system uses the virtual memory hardware to keep each process in its own virtual address space.

 

In the output of nm, etext is a symbol defined by the linker to let you know where the end of test is, and edata reports the address where the initialized data terminates.

1.2 What does the system (kernel) loader do?

·      The header in the binary file reports the memory size required for the program text, and the file keeps the memory image of that text. Therefore, the system can just copy all this into memory. For a given system and architecture, there is a convention regarding which addresses the program must use. Therefore, the system knows where to load the program.

·      The header in the binary reports the memory size required for initialized variables (global) and file contains a memory image for them. Thus, the system can copy those bytes to memory. Note that the system has no idea regarding where does one variable start or how big it is. The system only knows how many bytes it has to copy to memory, and at which address should they be copied.

·      For uninitialized global variables, the binary header reports their total size. The system allocates that amount of memory for the program. That is all it has to do. As a courtesy, Plan 9 guarantees that such memory is initialized with all bytes being zero. This means that all your global variables are initialized to null values by default.

1.3 Memory image for the global program

 

The virtual memory of a process in Plan 9 has several segments. A memory segment is a portion of contiguous memory with some properties. Segments used by a Plan 9 process are:

·      The test segment. It contains instructions that can be executed but not modified. The hardware is used by the system to enforce these permissions. The memory is initialized by the system with the program text (code) kept within the binary file for the program.

·      The data segment. It contains the initialized data for the program. Protection is set to allow both read and write operations on it, but you cannot execute instructions on it. The memory is initialized by the system using the initialized data kept within the binary file for the program.

·      The uninitialized data segment, called bss segment, which is almost like the data segment. However, this one is initialized by zeroing its memory. The name of the segment comes from an arcane instruction used to implement it on a machine that no longer exists. How much memory is given depends on the size recorded in the binary file. Moreover, this segment can grow, by using a system call that allocates more memory for it. Function libraries like malloc cause this segment to grow when they consume all the available memory in this segment. This is the reason for the gap between this segment and the stack segment, to leave room for the segment to grow.

·      The stack segment is also used for reading and writing memory. Unlike other segments, this segment seems to grow automatically when more space is used. It is used to keep the stack for the process.

1.4 Process Arguments

The macros ARGBEGIN and ARGEND loop through the argument list, removing and processing

options. After ARGEND, both argc and argv reflect the argument list without any option.

Between both macros, we must write the body for a switch statement (supplied by

ARGBEGIN), with a case per option.

 

 

Macros defined in plan9.h

extern char *argv0;
#define ARGBEGIN for((void)(argv0||(argv0=*argv)),argv++,argc--;/
       argv[0] && argv[0][0]=='-' && argv[0][1];/
       argc--, argv++) {/
    char *_args, *_argt;/
    Rune _argc;/
    _args = &argv[0][1];/
    if(_args[0]=='-' && _args[1]==0){/
     argc--; argv++; break;/
    }/
    _argc = 0;/
    while(*_args && (_args += chartorune(&_argc, _args)))/
    switch(_argc)
#define ARGEND  SET(_argt);USED(_argt);USED(_argc);USED(_args);}/
     USED(argv);USED(argc);
#define ARGF()  (_argt=_args, _args="",/
    (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
#define EARGF(x)  (_argt=_args, _args="",/
    (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
 
#define ARGC()  _argc
 
#define SET(x) (x) = 0
#define USED(x) (void)(x)

 

 

Most of the Plan 9 programs that accept multiple options use these macros to process their

argument list in search for options. This means that the invocation syntax is similar for most pro-grams. You may combine options in a single argument, use multiple arguments, supply arguments for options immediately after the option letter, or use another argument,

terminate the option list by giving a -- argument, and so on.

 

Source code of bind.c

 

#include <u.h>
#include <libc.h>
 
void usage(void);
 
void
main(int argc, char *argv[])
{
 ulong flag = 0;
 int qflag = 0;
 
 ARGBEGIN{
 case 'a':
  flag |= MAFTER;
  break;
 case 'b':
  flag |= MBEFORE;
  break;
 case 'c':
  flag |= MCREATE;
  break;
 case 'q':
  qflag = 1;
  break;
 default:
  usage();
 }ARGEND
 
 if(argc != 2 || (flag&MAFTER)&&(flag&MBEFORE))
  usage();
 
 if(bind(argv[0], argv[1], flag) < 0){
  if(qflag)
   exits(0);
  /* try to give a less confusing error than the default */
  if(access(argv[0], 0) < 0)
   fprint(2, "bind: %s: %r/n", argv[0]);
  else if(access(argv[1], 0) < 0)
   fprint(2, "bind: %s: %r/n", argv[1]);
  else
   fprint(2, "bind %s %s: %r/n", argv[0], argv[1]);
  exits("bind");
 }
 exits(0);
}
 
void
usage(void)
{
 fprint(2, "usage: bind [-b|-a|-c|-bc|-ac] new old/n");
 exits("usage");
}

 

 

1.5 System call errors

There are several ways of printing out the error string. The most convenient way is using the format “%r” in print.


There is a function that both prints a message and exits. It is called sysfatal, and is used like follows.


The system call rerrstr reads the error string. It stores the string at the buffer you supply.

The system call werrstr writes a new value for the error string. It is used like the print. Using it, we can implement a function that pops an element from a stack and reports errors nicely:

1.6 Environment

To obtain the value for a environment variable, from a C program, we can use the getenv system call. If the variable is not defined, getenv returns a null string. A related call is putenv, which accepts a name and a value, and set the corresponding environment variable accordingly.

 

 

#include <u.h>
#include <libc.h>
 
void main()
 
{
 char * path;
 
 path=getenv("path");
 if(path==nil)
  sysfatal("path not defined!");
 print("PATH is %s /n", path);
 
 exits(nil);
}

 

1.7 Process States


1.8 Debugging

The program src knows how to obtain the source file name and line number that corresponds to that program counter.

 

 ; src -n -s 0x000016ff 8.hi

  /sys/src/libc/fmt/dofmt.c:37

 

Option -n causes the source file name and line to be printed. Otherwise src would ask your editor to display your file and line. Option -s permits you to give a memory address or a symbol name to locate its source.

 

acid is the debugger can be used to dump the stack (function stk()), memory (function mem()) and so on.

 

Plan 9安装初体验

不知道什么是Plan 9? 请参见http://plan9.bell-labs.com/plan9/about.html 和 http://en.wikipedia.org/wiki/Plan_9_from_Bell_Labs

 

有5种方式可以安装或体验Plan 9:

  1. 在物理server上安装Plan 9操作系统,基本配置包括网络、文件服务器、CPU服务器以及终端,一般而言不适合个人体验。Plan 9已经被移植到IBM的Blue Gene/P上,和CNK一起工作(http://doc.cat-v.org/plan_9/blue_gene/)。
  2. 在虚拟机中安装Plan 9。支持Plan 9 ISO的虚拟机有QUME, VMware和Xen,VirtualBox支持的很差,很少有人能成功安装。
  3. 如果你有Plan9的CPU server而没有终端,可以使用drawterm在Unix/Linux上使用Plan 9。drawterm是跑在Unix/Linux上的一个应用程序。
  4. 在UNIX/Linux上使用plan9port。Plan 9项目失败后(2002~2003年)很多一直使用plan9的大牛们(如Russ Cox)回到*nix操作系统,他们把很多plan9的程序移植到了*nix上。
  5. 使用Russ Cox开发的vx32虚拟机的Plan 9实现9vx。9vx就像原生应用程序一样运行在Linux/FreeBSD/Solaris上,但是Windows暂不支持。

另外,推荐一篇非常好的Plan9使用入门的文章:A Plan9 Newbie's Guide。更多Plan9的资源可以在http://en.wikipedia.org/wiki/Plan_9_from_Bell_Labs的下面的连接处找到。

Your browser will not accept this data because of its Content-Encoding

今天打算在某个网站下载一个.bz2的文件时,遇到这样一个问题:

Your browser will not accept this data, /mirror.9grid.fr/plan9-1290391203/plan9.iso.bz2, because of its Content-Encoding.
Its Content-Type is application/octet-stream, and Content-Encoding is bzip2.
Your browser accepts Content-Type: */*, image/png, text/plain, text/html, application/xhtml+xml, application/xml.
Your browser accepts Content-Encoding: sdch, deflate, gzip.

我的浏览器是Chrome9 beta。

 

Google之后看到这样一个Firefox的解决方法:(原文 http://blog.1911census.co.uk/2009/01/content-encoding-error/

 

 

 

1) In the address bar type “about:config” (but without the inverted commas)
2) Tell it that you will be careful, Promise!!
3) In the filter type encoding
4) There should be one option reading “network.http.accept-encoding”
5) Click in the value column and type “true” (again without the inverted commas)
6) This should fix it and you can search to your hearts content.

 

试了一下,果然可行。

 

然后又搜索针对Chrome的类似的解决方案,半小时之后仍然无果 —— Chrome里没有“about:config”的支持。好在在 http://www.surfchen.org/archives/582 看到这样一句话:“chrome支持sdch压缩,另外不再支持bzip2压缩”,很是郁闷。

 

期待Chrome能早日支持“about:config”。

 

 

Debugging Perl

 How to Debug Perl Library and Scripts?

 

1. Changing
@INC - where Perl loads its modules
(http://www.wellho.net/mouth/588_Changing-INC-where-Perl-loads-its-modules.html) 

The
@
INC array
is a list of directories 
Perl searches
when attempting to load modules. 

Where
does Perl load modules from in its 
use and require statements?
It loads them from directorys in a special list called 
@INC,
from files with a .pm extension in those directorys. 
 
When
Perl's installed, @INC is set to a list of directorys that includes
generic locations for its standard modules, some release specific
directories, and "." the current directory, which are
checked in order each time you do a 
use or require
 
Some
ways to modify @INC
 

  • **
    You can add to the list in @INC by using the -I command line option:

perl
-I /Users/grahamellis/jan06 i2
 
says
"run the perl program i2, additionally checking the jan06
directory for modules" 

  • **
    You can add to the list within your program by doing so in a BEGIN
    block prior to the 
    use statements:

BEGIN

push @INC,"/Users/grahamellis/jan06"; 

use
demo; 
print "hello world"; 

Rather
curiously, 
use calls
are run at compile time not at run time ... but then so are BEGIN
blocks ... so you put your manipulation of @INC into one of those to
get it to happen early enough. 

  • **
    You can add to the beginning of the list by setting the PERL5LIB
    environment variable prior to running your program:

export
PERL5LIB=/Users/grahamellis/jan06
 

and
you can use a colon separated list for that if you want to pre-pend
more than one directory.

  • **There
    is also the "use lib" pragma - this is probably the most
    common approach. And $PERL5LIB can also be called just $PERLLIB.

2.
Debugging Perl http://ralphie.perlmonk.org/mosix/debug.html

To
check the syntax of your scripts, type "
perl
-c 
scriptname.pl
"
. It is also worthwhile to add the -w switch ("perl -cw ..."),
to turn on warning mode. If you were wise enough to "use strict"
in the body of the code, the syntax check will also specify
inappropriate scalar scoping, which goes a little beyond the normal
syntactical problems that are identified. Once your script will pass
through the syntax check with a "syntax ok" message, you
will have a legal perl script from the standpoint that all of the
statements are legal perl statements. That doesn't mean that the
manner in which any given statement is expressed will return the
result that you are looking for, that the functions that are used in
the code are the right ones for the job, or that the overall
structure of the script does anything like what you think it supposed
to do. It just means that all of the perl i's are dotted and t's are
crossed. (On the other hand, this is not such a minor thing, either.)

3.
perldebug

(
http://perldoc.perl.org/perldebug.html)

Calling
the debugger

There
are several ways to call the debugger:


  • perl -d program_name

On
the given program identified by program_name .


  • perl -d -e 0

Interactively
supply an arbitrary expression using -e .


  • perl -d:Ptkdb program_name

Debug
a given program via the Devel::Ptkdb GUI.


  • perl -dt
    threaded_program_name

Debug
a given program using threads (experimental).

4. Summary
of Subprocess Operations

Table
14.1: Summary of Subprocess Operations

Operation

Standard
Input

Standard
Output

Standard
Error

Waited
for?

system()

Inherited
from program

Inherited
from program

Inherited
from program

Yes

Backquoted
string

Inherited
from program

Captured as
string value

Inherited
from program

Yes

open() command
as filehandle for output

Connected to
filehandle

Inherited
from program

Inherited
from program

Only at time
of close()

open() command
as filehandle for input

Inherited
from program

Connected to
filehandle

Inherited
from program

Only at time
of close()

fork, exec, wait, waitpid

User
selected

User
selected

User
selected

User
selected

 

Above
table is from the book
Learning
Perl
.