<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet href='http://feed.so8848.com/styles/feedsky2.xsl' type='text/xsl' ?><!--这是一个由Feedsy提供技术支持的Feed，为了提高读者阅读的体验，以及满足用户美化自己Feed的需要，我们设计了多种精美的Feed模板，提供给大家选择，所有最终呈现出来的样式，皆由用户自愿选择使用，未经许可，任何团体和个人，请不要擅自修改样式或者盗用，这是对于用户选择权的尊重。--><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:fs="http://www.feedsky.com/namespace/feed" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:gr="http://www.google.com/schemas/reader/atom/" version="2.0"><channel><atom:link href="http://feed.so8848.com" type="application/rss+xml" rel="self"></atom:link><fs:self_link href="http://feed.feedsky.com/yahooblog" type="application/rss+xml"></fs:self_link><lastBuildDate>Wed, 07 Dec 2011 05:30:39 GMT</lastBuildDate><title>Information Retrieval Blog</title><description>WEB, IR, Search, Mining</description><image><url>http://www.feedsky.com/feed/yahooblog/sc/gif</url><title>Information Retrieval Blog</title><link>http://blog.so8848.com</link></image><link>http://blog.so8848.com</link><sy:updatePeriod>hourly</sy:updatePeriod><sy:updateFrequency>1</sy:updateFrequency><language>en</language><pubDate>Fri, 13 Jan 2012 17:13:07 GMT</pubDate><item><title>Linux commands</title><link>http://item.feedsky.com/~feedsky/yahooblog/~7260371/596885650/5002429/1/item.html</link><content:encoded>&lt;table&gt;
&lt;tbody&gt;
&lt;tr id=&quot;misc&quot;&gt;
&lt;td colspan=&quot;2&quot;&gt;&lt;strong&gt;Command&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;apropos whatis&lt;/td&gt;
&lt;td&gt;Show commands pertinent to string. See also &lt;a href=&quot;http://www.pixelbeat.org/scripts/threadsafe&quot;&gt;threadsafe&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;http://www.pixelbeat.org/lkdb/less.html&quot;&gt;man&lt;/a&gt; -t man | ps2pdf &amp;#8211; &amp;gt; man.pdf&lt;/td&gt;
&lt;td&gt;make a pdf of a manual page&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;which command&lt;/td&gt;
&lt;td&gt;Show full path name of command&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;time command&lt;/td&gt;
&lt;td&gt;See how long a command takes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;time cat&lt;/td&gt;
&lt;td&gt;Start stopwatch. Ctrl-d to stop. See also &lt;a href=&quot;http://www.pixelbeat.org/scripts/stopwatch/&quot;&gt;sw&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr id=&quot;dirs&quot;&gt;
&lt;td colspan=&quot;3&quot;&gt;&lt;strong&gt;dir navigation&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;cd -&lt;/td&gt;
&lt;td&gt;Go to previous directory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;cd&lt;/td&gt;
&lt;td&gt;Go to $HOME directory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;(cd dir &amp;amp;&amp;amp; command)&lt;/td&gt;
&lt;td&gt;Go to dir, execute command and return to current dir&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;pushd &lt;strong&gt;.&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Put current dir on stack so you can &lt;strong&gt;popd&lt;/strong&gt; back to it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr id=&quot;file_search&quot;&gt;
&lt;td colspan=&quot;3&quot;&gt;&lt;strong&gt;file searching&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;http://www.pixelbeat.org/settings/.bashrc&quot;&gt;alias&lt;/a&gt; l=&amp;#8217;ls -l &amp;#8211;color=auto&amp;#8217;&lt;/td&gt;
&lt;td&gt;quick dir listing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;ls -lrt&lt;/td&gt;
&lt;td&gt;List files by date. See also &lt;a href=&quot;http://www.pixelbeat.org/scripts/newest&quot;&gt;newest&lt;/a&gt; and &lt;a href=&quot;http://www.pixelbeat.org/scripts/find_mm_yyyy&quot;&gt;find_mm_yyyy&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;ls /usr/bin | pr -T9 -W$COLUMNS&lt;/td&gt;
&lt;td&gt;Print in 9 columns to width of terminal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;find -name &amp;#8216;*.[ch]&amp;#8216; | xargs grep -E &amp;#8216;expr&amp;#8217;&lt;/td&gt;
&lt;td&gt;Search &amp;#8216;expr&amp;#8217; in this dir and below. See also &lt;a href=&quot;http://www.pixelbeat.org/scripts/findrepo&quot;&gt;findrepo&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;find -type f -print0 | xargs -r0 grep -F &amp;#8216;example&amp;#8217;&lt;/td&gt;
&lt;td&gt;Search all regular files for &amp;#8216;example&amp;#8217; in this dir and below&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;find -maxdepth 1 -type f | xargs grep -F &amp;#8216;example&amp;#8217;&lt;/td&gt;
&lt;td&gt;Search all regular files for &amp;#8216;example&amp;#8217; in this dir&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;find -maxdepth 1 -type d | while &lt;a href=&quot;http://www.pixelbeat.org/programming/readline/&quot;&gt;read&lt;/a&gt; dir; do echo $dir; echo cmd2; done&lt;/td&gt;
&lt;td&gt;Process each item with multiple commands (in while loop)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;find -type f ! -perm -444&lt;/td&gt;
&lt;td&gt;Find files not readable by all (useful for web site)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;find -type d ! -perm -111&lt;/td&gt;
&lt;td&gt;Find dirs not accessible by all (useful for web site)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;locate -r &amp;#8216;file[^/]*.txt&amp;#8217;&lt;/td&gt;
&lt;td&gt;Search cached index for names. This re is like glob *file*.txt&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;look reference&lt;/td&gt;
&lt;td&gt;Quickly search (sorted) dictionary for prefix&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;grep &lt;a href=&quot;http://www.pixelbeat.org/settings/.bashrc&quot;&gt;&amp;#8211;color&lt;/a&gt; reference /usr/share/dict/words&lt;/td&gt;
&lt;td&gt;Highlight occurances of regular expression in dictionary&lt;/td&gt;
&lt;/tr&gt;
&lt;tr id=&quot;archives&quot;&gt;
&lt;td colspan=&quot;3&quot;&gt;&lt;strong&gt;archives and compression&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;gpg -c file&lt;/td&gt;
&lt;td&gt;Encrypt file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;gpg file.gpg&lt;/td&gt;
&lt;td&gt;Decrypt file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;tar -c dir/ | bzip2 &amp;gt; dir.tar.bz2&lt;/td&gt;
&lt;td&gt;Make compressed archive of dir/&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;bzip2 -dc dir.tar.bz2 | tar -x&lt;/td&gt;
&lt;td&gt;Extract archive (use gzip instead of bzip2 for tar.gz files)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;tar -c dir/ | gzip | gpg -c | ssh user@remote &amp;#8216;dd of=dir.tar.gz.gpg&amp;#8217;&lt;/td&gt;
&lt;td&gt;Make encrypted archive of dir/ on remote machine&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;find dir/ -name &amp;#8216;*.txt&amp;#8217; | tar -c &amp;#8211;files-from=- | bzip2 &amp;gt; dir_txt.tar.bz2&lt;/td&gt;
&lt;td&gt;Make archive of subset of dir/ and below&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;find dir/ -name &amp;#8216;*.txt&amp;#8217; | xargs cp -a &amp;#8211;target-directory=dir_txt/ &amp;#8211;parents&lt;/td&gt;
&lt;td&gt;Make copy of subset of dir/ and below&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;( tar -c /dir/to/copy ) | ( cd /where/to/ &amp;amp;&amp;amp; tar -x -p )&lt;/td&gt;
&lt;td&gt;Copy (with permissions) copy/ dir to /where/to/ dir&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;( cd /dir/to/copy &amp;amp;&amp;amp; tar -c &lt;strong&gt;.&lt;/strong&gt; ) | ( cd /where/to/ &amp;amp;&amp;amp; tar -x -p )&lt;/td&gt;
&lt;td&gt;Copy (with permissions) contents of copy/ dir to /where/to/&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;( tar -c /dir/to/copy ) | ssh -C user@remote &amp;#8216;cd /where/to/ &amp;amp;&amp;amp; tar -x -p&amp;#8217;&lt;/td&gt;
&lt;td&gt;Copy (with permissions) copy/ dir to remote:/where/to/ dir&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;dd bs=1M if=/dev/sda | gzip | ssh user@remote &amp;#8216;dd of=sda.gz&amp;#8217;&lt;/td&gt;
&lt;td&gt;Backup harddisk to remote machine&lt;/td&gt;
&lt;/tr&gt;
&lt;tr id=&quot;rsync&quot;&gt;
&lt;td colspan=&quot;3&quot;&gt;&lt;strong&gt;rsync&lt;/strong&gt; (Network efficient file copier: Use the &amp;#8211;dry-run option for testing)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;rsync -P rsync://rsync.server.com/path/to/file file&lt;/td&gt;
&lt;td&gt;Only get diffs. Do multiple times for troublesome downloads&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;rsync &amp;#8211;bwlimit=1000 fromfile tofile&lt;/td&gt;
&lt;td&gt;Locally copy with rate limit. It&amp;#8217;s like nice for I/O&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;rsync -az -e ssh &amp;#8211;delete ~/public_html/ remote.com:&amp;#8217;~/public_html&amp;#8217;&lt;/td&gt;
&lt;td&gt;Mirror web site (using compression and encryption)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;rsync -auz -e ssh remote:/dir/ &lt;strong&gt;.&lt;/strong&gt; &amp;amp;&amp;amp; rsync -auz -e ssh &lt;strong&gt;.&lt;/strong&gt; remote:/dir/&lt;/td&gt;
&lt;td&gt;Synchronize current directory with remote one&lt;/td&gt;
&lt;/tr&gt;
&lt;tr id=&quot;ssh&quot;&gt;
&lt;td colspan=&quot;3&quot;&gt;&lt;strong&gt;ssh&lt;/strong&gt; (Secure SHell)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;ssh $USER@$HOST command&lt;/td&gt;
&lt;td&gt;Run command on $HOST as $USER (default command=shell)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;ssh -f -Y $USER@$HOSTNAME xeyes&lt;/td&gt;
&lt;td&gt;Run GUI command on $HOSTNAME as $USER&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;scp -p -r $USER@$HOST: file dir/&lt;/td&gt;
&lt;td&gt;Copy with permissions to $USER&amp;#8217;s home directory on $HOST&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;ssh -g -L 8080:localhost:80 root@$HOST&lt;/td&gt;
&lt;td&gt;Forward connections to $HOSTNAME:8080 out to $HOST:80&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;ssh -R 1434:imap:143 root@$HOST&lt;/td&gt;
&lt;td&gt;Forward connections from $HOST:1434 in to imap:143&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;ssh-copy-id $USER@$HOST&lt;/td&gt;
&lt;td&gt;Install $USER&amp;#8217;s public key on $HOST for password-less log in&lt;/td&gt;
&lt;/tr&gt;
&lt;tr id=&quot;wget&quot;&gt;
&lt;td colspan=&quot;3&quot;&gt;&lt;strong&gt;wget&lt;/strong&gt; (multi purpose download tool)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;(cd dir/ &amp;amp;&amp;amp; wget -nd -pHEKk http://www.pixelbeat.org/cmdline.html)&lt;/td&gt;
&lt;td&gt;Store local browsable version of a page to the current dir&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;wget -c http://www.example.com/large.file&lt;/td&gt;
&lt;td&gt;Continue downloading a partially downloaded file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;wget -r -nd -np -l1 -A &amp;#8216;*.jpg&amp;#8217; http://www.example.com/dir/&lt;/td&gt;
&lt;td&gt;Download a set of files to the current directory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;wget ftp://remote/file[1-9].iso/&lt;/td&gt;
&lt;td&gt;FTP supports globbing directly&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;wget -q -O- http://www.pixelbeat.org/timeline.html | grep &amp;#8216;a href&amp;#8217; | head&lt;/td&gt;
&lt;td&gt;Process output directly&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;echo &amp;#8216;wget url&amp;#8217; | at 01:00&lt;/td&gt;
&lt;td&gt;Download url at 1AM to current dir&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;wget &amp;#8211;limit-rate=20k url&lt;/td&gt;
&lt;td&gt;Do a low priority download (limit to 20&lt;a href=&quot;http://www.pixelbeat.org/speeds.html&quot;&gt;KB/s&lt;/a&gt; in this case)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;wget -nv &amp;#8211;spider &amp;#8211;force-html -i bookmarks.html&lt;/td&gt;
&lt;td&gt;Check links in a file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;wget &amp;#8211;mirror http://www.example.com/&lt;/td&gt;
&lt;td&gt;Efficiently update a local copy of a site (handy from cron)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr id=&quot;net&quot;&gt;
&lt;td colspan=&quot;3&quot;&gt;&lt;strong&gt;networking&lt;/strong&gt; (Note ifconfig, route, mii-tool, nslookup commands are obsolete)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;acronym title=&quot;usually in /sbin/&quot;&gt;ethtool&lt;/acronym&gt; eth0&lt;/td&gt;
&lt;td&gt;Show status of ethernet interface eth0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;ethtool &amp;#8211;change eth0 autoneg off speed 100 duplex full&lt;/td&gt;
&lt;td&gt;Manually set ethernet interface speed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;acronym title=&quot;usually in /sbin/&quot;&gt;iwconfig&lt;/acronym&gt; eth1&lt;/td&gt;
&lt;td&gt;Show status of wireless interface eth1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;iwconfig eth1 rate 1Mb/s fixed&lt;/td&gt;
&lt;td&gt;Manually set wireless interface speed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;&lt;acronym title=&quot;usually in /sbin/&quot;&gt;iwlist&lt;/acronym&gt; scan&lt;/td&gt;
&lt;td&gt;List wireless networks in range&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;&lt;acronym title=&quot;usually in /sbin/&quot;&gt;ip&lt;/acronym&gt; link show&lt;/td&gt;
&lt;td&gt;List network interfaces&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;ip link set dev eth0 name wan&lt;/td&gt;
&lt;td&gt;Rename interface eth0 to wan&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;ip link set dev eth0 up&lt;/td&gt;
&lt;td&gt;Bring interface eth0 up (or down)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;ip addr show&lt;/td&gt;
&lt;td&gt;List addresses for interfaces&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;ip addr add 1.2.3.4/24 brd + dev eth0&lt;/td&gt;
&lt;td&gt;Add (or del) ip and mask (255.255.255.0)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;ip route show&lt;/td&gt;
&lt;td&gt;List routing table&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;ip route add default via 1.2.3.254&lt;/td&gt;
&lt;td&gt;Set default gateway to 1.2.3.254&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;host pixelbeat.org&lt;/td&gt;
&lt;td&gt;Lookup DNS ip address for name or vice versa&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;hostname -i&lt;/td&gt;
&lt;td&gt;Lookup local ip address (equivalent to host `hostname`)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;whois pixelbeat.org&lt;/td&gt;
&lt;td&gt;Lookup whois info for hostname or ip address&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;netstat -tupl&lt;/td&gt;
&lt;td&gt;List internet services on a system&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;netstat -tup&lt;/td&gt;
&lt;td&gt;List active connections to/from system&lt;/td&gt;
&lt;/tr&gt;
&lt;tr id=&quot;windows&quot;&gt;
&lt;td colspan=&quot;3&quot;&gt;&lt;strong&gt;windows networking&lt;/strong&gt; (Note samba is the package that provides all this windows specific networking support)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;smbtree&lt;/td&gt;
&lt;td&gt;Find windows machines. See also findsmb&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;nmblookup -A 1.2.3.4&lt;/td&gt;
&lt;td&gt;Find the windows (netbios) name associated with ip address&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;smbclient -L windows_box&lt;/td&gt;
&lt;td&gt;List shares on windows machine or samba server&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;mount -t smbfs -o fmask=666,guest //windows_box/share /mnt/share&lt;/td&gt;
&lt;td&gt;Mount a windows share&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;echo &amp;#8216;message&amp;#8217; | smbclient -M windows_box&lt;/td&gt;
&lt;td&gt;Send popup to windows machine (off by default in XP sp2)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr id=&quot;text&quot;&gt;
&lt;td colspan=&quot;3&quot;&gt;&lt;strong&gt;text manipulation&lt;/strong&gt; (Note sed uses stdin and stdout. Newer versions support inplace editing with the -i option)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;sed &amp;#8216;s/string1/string2/g&amp;#8217;&lt;/td&gt;
&lt;td&gt;Replace string1 with string2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;sed &amp;#8216;s/(.*)1/12/g&amp;#8217;&lt;/td&gt;
&lt;td&gt;Modify anystring1 to anystring2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;sed &amp;#8216;/ *#/d; /^ *$/d&amp;#8217;&lt;/td&gt;
&lt;td&gt;Remove comments and blank lines&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;sed &amp;#8216;:a; /\$/N; s/\n//; ta&amp;#8217;&lt;/td&gt;
&lt;td&gt;Concatenate lines with trailing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;sed &amp;#8216;s/[ t]*$//&amp;#8217;&lt;/td&gt;
&lt;td&gt;Remove trailing spaces from lines&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;sed &amp;#8216;s/([`&quot;$])/\1/g&amp;#8217;&lt;/td&gt;
&lt;td&gt;Escape shell metacharacters active within double quotes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;seq 10 | sed &amp;#8220;s/^/      /; s/ *(.{7,})/1/&amp;#8221;&lt;/td&gt;
&lt;td&gt;Right align numbers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;sed -n &amp;#8217;1000{p;&lt;acronym title=&quot;quit ASAP&quot;&gt;q&lt;/acronym&gt;}&amp;#8217;&lt;/td&gt;
&lt;td&gt;Print 1000th line&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;sed -n &amp;#8217;10,20p;&lt;acronym title=&quot;quit ASAP&quot;&gt;20q&lt;/acronym&gt;&amp;#8216;&lt;/td&gt;
&lt;td&gt;Print lines 10 to 20&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;sed -n &amp;#8216;s/.*&amp;lt;title&amp;gt;(.*)&amp;lt;/title&amp;gt;.*/1/ip;&lt;acronym title=&quot;quit after match&quot;&gt;T;q&lt;/acronym&gt;&amp;#8216;&lt;/td&gt;
&lt;td&gt;Extract title from HTML web page&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;sed -i 42d ~/.ssh/known_hosts&lt;/td&gt;
&lt;td&gt;Delete a particular line&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;sort -t. -k1,1n -k2,2n -k3,3n -k4,4n&lt;/td&gt;
&lt;td&gt;Sort IPV4 ip addresses&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;echo &amp;#8216;Test&amp;#8217; | tr &amp;#8216;[:lower:]&amp;#8216; &amp;#8216;[:upper:]&amp;#8216;&lt;/td&gt;
&lt;td&gt;Case conversion&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;tr -dc &amp;#8216;[:print:]&amp;#8216; &amp;lt; /dev/urandom&lt;/td&gt;
&lt;td&gt;Filter non printable characters&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;tr -s &amp;#8216;[:blank:]&amp;#8216; &amp;#8216;t&amp;#8217; &amp;lt;/proc/diskstats | cut -f4&lt;/td&gt;
&lt;td&gt;cut fields separated by blanks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;history | wc -l&lt;/td&gt;
&lt;td&gt;Count lines&lt;/td&gt;
&lt;/tr&gt;
&lt;tr id=&quot;sets&quot;&gt;
&lt;td colspan=&quot;3&quot;&gt;&lt;strong&gt;set operations&lt;/strong&gt; (Note you can &lt;a href=&quot;http://www.pixelbeat.org/docs/env.html&quot;&gt;export LANG=C&lt;/a&gt; for speed. Also these assume no duplicate lines within a file)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;sort file1 file2 | uniq&lt;/td&gt;
&lt;td&gt;&lt;acronym title=&quot;Items in either file1 or file2&quot;&gt;Union&lt;/acronym&gt; of unsorted files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;sort file1 file2 | uniq -d&lt;/td&gt;
&lt;td&gt;&lt;acronym title=&quot;Items both in file1 and file2&quot;&gt;Intersection&lt;/acronym&gt; of unsorted files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;sort file1 file1 file2 | uniq -u&lt;/td&gt;
&lt;td&gt;&lt;acronym title=&quot;Items in file2 not in file1&quot;&gt;Difference&lt;/acronym&gt; of unsorted files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;sort file1 file2 | uniq -u&lt;/td&gt;
&lt;td&gt;&lt;acronym title=&quot;Items in only one file&quot;&gt;Symmetric Difference&lt;/acronym&gt; of unsorted files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;join &lt;acronym title=&quot;process whole line (assuming no NUL characters present)&quot;&gt;-t&amp;#8217;�&amp;#8217;&lt;/acronym&gt; -a1 -a2 file1 file2&lt;/td&gt;
&lt;td&gt;Union of sorted files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;join -t&amp;#8217;�&amp;#8217; file1 file2&lt;/td&gt;
&lt;td&gt;Intersection of sorted files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;join -t&amp;#8217;�&amp;#8217; -v2 file1 file2&lt;/td&gt;
&lt;td&gt;Difference of sorted files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;join -t&amp;#8217;�&amp;#8217; -v1 -v2 file1 file2&lt;/td&gt;
&lt;td&gt;Symmetric Difference of sorted files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr id=&quot;math&quot;&gt;
&lt;td colspan=&quot;3&quot;&gt;&lt;strong&gt;math&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;echo &amp;#8216;(1 + sqrt(5))/2&amp;#8242; | bc -l&lt;/td&gt;
&lt;td&gt;Quick math (Calculate φ). See also &lt;a href=&quot;http://www.pixelbeat.org/scripts/bc&quot;&gt;bc&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;echo &amp;#8216;pad=20; min=64; (100*10^6)/((pad+min)*8)&amp;#8217; | bc&lt;/td&gt;
&lt;td&gt;More complex (int) e.g. This shows max FastE packet rate&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;echo &amp;#8216;pad=20; min=64; print (100E6)/((pad+min)*8)&amp;#8217; | python&lt;/td&gt;
&lt;td&gt;Python handles scientific notation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;echo &amp;#8216;pad=20; plot [64:1518] (100*10**6)/((pad+x)*8)&amp;#8217; | gnuplot -persist&lt;/td&gt;
&lt;td&gt;Plot FastE packet rate vs packet size&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;echo &amp;#8216;obase=16; ibase=10; 64206&amp;#8242; | bc&lt;/td&gt;
&lt;td&gt;Base conversion (decimal to hexadecimal)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;echo $((0x2dec))&lt;/td&gt;
&lt;td&gt;Base conversion (hex to dec) ((shell arithmetic expansion))&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;units -t &amp;#8217;100m/&lt;a href=&quot;http://www.pixelbeat.org/misc/usain_bolt/&quot;&gt;9.58s&lt;/a&gt;&amp;#8216; &amp;#8216;miles/hour&amp;#8217;&lt;/td&gt;
&lt;td&gt;Unit conversion (metric to imperial)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;units -t &amp;#8217;500GB&amp;#8217; &amp;#8216;GiB&amp;#8217;&lt;/td&gt;
&lt;td&gt;Unit conversion (&lt;acronym title=&quot;powers of 10&quot;&gt;SI&lt;/acronym&gt; to &lt;acronym title=&quot;powers of 2&quot;&gt;IEC&lt;/acronym&gt; prefixes)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;units -t &amp;#8217;1 googol&amp;#8217;&lt;/td&gt;
&lt;td&gt;Definition lookup&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;seq 100 | (tr &amp;#8216;n&amp;#8217; +; echo 0) | bc&lt;/td&gt;
&lt;td&gt;Add a column of numbers. See also &lt;a href=&quot;http://www.pixelbeat.org/scripts/add&quot;&gt;add&lt;/a&gt; and &lt;a href=&quot;http://www.pixelbeat.org/scripts/funcpy&quot;&gt;funcpy&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr id=&quot;dates&quot;&gt;
&lt;td colspan=&quot;3&quot;&gt;&lt;strong&gt;calendar&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;cal -3&lt;/td&gt;
&lt;td&gt;Display a calendar&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;cal 9 1752&lt;/td&gt;
&lt;td&gt;Display a calendar for a particular month year&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;date -d fri&lt;/td&gt;
&lt;td&gt;What date is it this friday. See also &lt;a href=&quot;http://www.pixelbeat.org/scripts/day&quot;&gt;day&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;[ $(date -d &quot;tomorrow&quot; +%d) = &quot;01&quot; ] || exit&lt;/td&gt;
&lt;td&gt;exit a script unless it&amp;#8217;s the last day of the month&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;date &amp;#8211;date=&amp;#8217;25 Dec&amp;#8217; +%A&lt;/td&gt;
&lt;td&gt;What day does xmas fall on, this year&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;date &amp;#8211;date=&amp;#8217;@2147483647&amp;#8242;&lt;/td&gt;
&lt;td&gt;Convert seconds since the epoch (1970-01-01 UTC) to date&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;TZ=&amp;#8217;America/Los_Angeles&amp;#8217; date&lt;/td&gt;
&lt;td&gt;What time is it on west coast of US (use tzselect to find TZ)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;date &amp;#8211;date=&amp;#8217;TZ=&amp;#8221;America/Los_Angeles&amp;#8221; 09:00 next Fri&amp;#8217;&lt;/td&gt;
&lt;td&gt;What&amp;#8217;s the local time for 9AM next Friday on west coast US&lt;/td&gt;
&lt;/tr&gt;
&lt;tr id=&quot;locale&quot;&gt;
&lt;td colspan=&quot;3&quot;&gt;&lt;strong&gt;locales&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;printf &amp;#8220;%&amp;#8217;dn&amp;#8221; 1234&lt;/td&gt;
&lt;td&gt;Print number with thousands grouping appropriate to locale&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;BLOCK_SIZE=&amp;#8217;1 ls -l&lt;/td&gt;
&lt;td&gt;Use locale thousands grouping in ls. See also &lt;a href=&quot;http://www.pixelbeat.org/scripts/l&quot;&gt;l&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;echo &amp;#8220;I live in `locale territory`&amp;#8221;&lt;/td&gt;
&lt;td&gt;Extract info from locale database&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;LANG=en_IE.utf8 locale int_prefix&lt;/td&gt;
&lt;td&gt;Lookup locale info for specific country. See also &lt;a href=&quot;http://www.pixelbeat.org/scripts/ccodes&quot;&gt;ccodes&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;locale | cut -d= -f1 | xargs locale -kc | less&lt;/td&gt;
&lt;td&gt;List fields available in locale database&lt;/td&gt;
&lt;/tr&gt;
&lt;tr id=&quot;recode&quot;&gt;
&lt;td colspan=&quot;3&quot;&gt;&lt;strong&gt;recode&lt;/strong&gt; (Obsoletes iconv, dos2unix, unix2dos)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;recode -l | less&lt;/td&gt;
&lt;td&gt;Show available conversions (aliases on each line)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;recode windows-1252.. file_to_change.txt&lt;/td&gt;
&lt;td&gt;Windows &amp;#8220;ansi&amp;#8221; to local charset (auto does CRLF conversion)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;recode utf-8/CRLF.. file_to_change.txt&lt;/td&gt;
&lt;td&gt;Windows utf8 to local charset&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;recode iso-8859-15..utf8 file_to_change.txt&lt;/td&gt;
&lt;td&gt;Latin9 (western europe) to utf8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;recode ../b64 &amp;lt; file.txt &amp;gt; file.b64&lt;/td&gt;
&lt;td&gt;Base64 encode&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;recode /qp.. &amp;lt; file.qp &amp;gt; file.txt&lt;/td&gt;
&lt;td&gt;Quoted printable decode&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;recode ..HTML &amp;lt; file.txt &amp;gt; file.html&lt;/td&gt;
&lt;td&gt;Text to HTML&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;recode -lf windows-1252 | grep euro&lt;/td&gt;
&lt;td&gt;Lookup &lt;a href=&quot;http://www.pixelbeat.org/docs/utf8.html&quot;&gt;table of characters&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;echo -n 0&amp;#215;80 | recode latin-9/x1..dump&lt;/td&gt;
&lt;td&gt;Show what a code represents in latin-9 charmap&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;echo -n 0x20AC | recode ucs-2/x2..latin-9/x&lt;/td&gt;
&lt;td&gt;Show latin-9 encoding&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;echo -n 0x20AC | recode ucs-2/x2..utf-8/x&lt;/td&gt;
&lt;td&gt;Show utf-8 encoding&lt;/td&gt;
&lt;/tr&gt;
&lt;tr id=&quot;CDs&quot;&gt;
&lt;td colspan=&quot;3&quot;&gt;&lt;strong&gt;&lt;acronym title=&quot;Compact Disks&quot;&gt;CDs&lt;/acronym&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;gzip &amp;lt; /dev/cdrom &amp;gt; cdrom.iso.gz&lt;/td&gt;
&lt;td&gt;Save copy of data cdrom&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;mkisofs -V LABEL -r dir | gzip &amp;gt; cdrom.iso.gz&lt;/td&gt;
&lt;td&gt;Create cdrom image from contents of dir&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;mount -o loop cdrom.iso /mnt/dir&lt;/td&gt;
&lt;td&gt;Mount the cdrom image at /mnt/dir (read only)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;cdrecord -v dev=/dev/cdrom blank=fast&lt;/td&gt;
&lt;td&gt;Clear a CDRW&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;gzip -dc cdrom.iso.gz | cdrecord -v dev=/dev/cdrom -&lt;/td&gt;
&lt;td&gt;Burn cdrom image (use dev=ATAPI -scanbus to confirm dev)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;cdparanoia -B&lt;/td&gt;
&lt;td&gt;Rip audio tracks from CD to wav files in current dir&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;cdrecord -v dev=/dev/cdrom -audio -pad *.wav&lt;/td&gt;
&lt;td&gt;Make audio CD from all wavs in current dir (see also cdrdao)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;oggenc &amp;#8211;tracknum=&amp;#8217;track&amp;#8217; track.cdda.wav -o &amp;#8216;track.ogg&amp;#8217;&lt;/td&gt;
&lt;td&gt;Make ogg file from wav file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr id=&quot;disk_space&quot;&gt;
&lt;td colspan=&quot;3&quot;&gt;&lt;strong&gt;disk space&lt;/strong&gt; (See also &lt;a href=&quot;http://www.pixelbeat.org/fslint/&quot;&gt;FSlint&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;ls -lSr&lt;/td&gt;
&lt;td&gt;Show files by size, biggest last&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;du -s * | sort -k1,1rn | head&lt;/td&gt;
&lt;td&gt;Show top disk users in current dir. See also &lt;a href=&quot;http://www.pixelbeat.org/scripts/dutop&quot;&gt;dutop&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;du -hs /home/* | sort -k1,1&lt;acronym title=&quot;available since coreutils 7.5&quot;&gt;h&lt;/acronym&gt;&lt;/td&gt;
&lt;td&gt;Sort paths by easy to interpret disk usage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;df -h&lt;/td&gt;
&lt;td&gt;Show free space on mounted filesystems&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;df -i&lt;/td&gt;
&lt;td&gt;Show free inodes on mounted filesystems&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;&lt;acronym title=&quot;usually in /sbin/&quot;&gt;fdisk&lt;/acronym&gt; -l&lt;/td&gt;
&lt;td&gt;Show disks partitions sizes and types (run as root)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;http://www.pixelbeat.org/docs/packaging.html&quot;&gt;rpm&lt;/a&gt; -q -a &amp;#8211;qf &amp;#8216;%10{SIZE}t%{NAME}n&amp;#8217; | sort -k1,1n&lt;/td&gt;
&lt;td&gt;List all &lt;a href=&quot;http://www.pixelbeat.org/docs/packaging.html&quot;&gt;packages&lt;/a&gt; by installed size (Bytes) on rpm distros&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;http://www.pixelbeat.org/docs/packaging.html&quot;&gt;dpkg&lt;/a&gt;-query -W -f=&amp;#8217;${Installed-Size;10}t${Package}n&amp;#8217; | sort -k1,1n&lt;/td&gt;
&lt;td&gt;List all &lt;a href=&quot;http://www.pixelbeat.org/docs/packaging.html&quot;&gt;packages&lt;/a&gt; by installed size (KBytes) on deb distros&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;dd bs=1 seek=2TB if=/dev/null of=ext3.test&lt;/td&gt;
&lt;td&gt;Create a large test file (taking no space). See also &lt;a href=&quot;http://www.pixelbeat.org/scripts/truncate&quot;&gt;truncate&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;&amp;gt; file&lt;/td&gt;
&lt;td&gt;truncate data of file or create an empty file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr id=&quot;monitor&quot;&gt;
&lt;td colspan=&quot;3&quot;&gt;&lt;strong&gt;monitoring/debugging&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;tail -f /var/log/messages&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;http://www.pixelbeat.org/docs/web/access_log/monitoring.html&quot;&gt;Monitor messages&lt;/a&gt; in a log file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;strace -c ls &amp;gt;/dev/null&lt;/td&gt;
&lt;td&gt;Summarise/profile system calls made by command&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;strace -f -e open ls &amp;gt;/dev/null&lt;/td&gt;
&lt;td&gt;List system calls made by command&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;ltrace -f -e getenv ls &amp;gt;/dev/null&lt;/td&gt;
&lt;td&gt;List library calls made by command&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;&lt;acronym title=&quot;usually in /usr/sbin/&quot;&gt;lsof&lt;/acronym&gt; -p &lt;acronym title=&quot;process id of current shell&quot;&gt;$&lt;/acronym&gt;&lt;/td&gt;
&lt;td&gt;List paths that process id has open&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;lsof ~&lt;/td&gt;
&lt;td&gt;List processes that have specified path open&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;tcpdump not port 22&lt;/td&gt;
&lt;td&gt;Show network traffic except ssh. See also &lt;a href=&quot;http://www.pixelbeat.org/scripts/tcpdump_not_me&quot;&gt;tcpdump_not_me&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;ps -e -o pid,args &amp;#8211;forest&lt;/td&gt;
&lt;td&gt;List processes in a hierarchy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;ps -e -o pcpu,cpu,nice,state,cputime,args &amp;#8211;sort pcpu | sed &amp;#8216;/^ 0.0 /d&amp;#8217;&lt;/td&gt;
&lt;td&gt;List processes by % cpu usage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS&lt;/td&gt;
&lt;td&gt;List processes by mem (KB) usage. See also &lt;a href=&quot;http://www.pixelbeat.org/scripts/ps_mem.py&quot;&gt;ps_mem.py&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;ps -C firefox-bin -L -o pid,tid,pcpu,state&lt;/td&gt;
&lt;td&gt;List all threads for a particular process&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;ps -p 1,$ -o etime=&lt;/td&gt;
&lt;td&gt;List elapsed wall time for particular process IDs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;last reboot&lt;/td&gt;
&lt;td&gt;Show system reboot history&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;free -m&lt;/td&gt;
&lt;td&gt;Show amount of (remaining) RAM (-m displays in MB)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;watch -n.1 &amp;#8216;cat /proc/interrupts&amp;#8217;&lt;/td&gt;
&lt;td&gt;Watch changeable data continuously&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;udevadm monitor&lt;/td&gt;
&lt;td&gt;Monitor udev events to help configure rules&lt;/td&gt;
&lt;/tr&gt;
&lt;tr id=&quot;sysinfo&quot;&gt;
&lt;td colspan=&quot;3&quot;&gt;&lt;strong&gt;system information&lt;/strong&gt; (see also &lt;a href=&quot;http://www.pixelbeat.org/scripts/sysinfo&quot;&gt;sysinfo&lt;/a&gt;) (&amp;#8216;#&amp;#8217; means root access is required)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;uname -a&lt;/td&gt;
&lt;td&gt;Show kernel version and system architecture&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;head -n1 /etc/issue&lt;/td&gt;
&lt;td&gt;Show name and version of distribution&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;cat /proc/partitions&lt;/td&gt;
&lt;td&gt;Show all partitions registered on the system&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;grep MemTotal /proc/meminfo&lt;/td&gt;
&lt;td&gt;Show RAM total seen by the system&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;grep &amp;#8220;model name&amp;#8221; /proc/cpuinfo&lt;/td&gt;
&lt;td&gt;Show CPU(s) info&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;&lt;acronym title=&quot;usually in /sbin/&quot;&gt;lspci&lt;/acronym&gt; -tv&lt;/td&gt;
&lt;td&gt;Show PCI info&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;&lt;acronym title=&quot;usually in /sbin/&quot;&gt;lsusb&lt;/acronym&gt; -tv&lt;/td&gt;
&lt;td&gt;Show USB info&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;mount | column -t&lt;/td&gt;
&lt;td&gt;List mounted filesystems on the system (and align output)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;grep -F capacity: /proc/acpi/battery/BAT0/info&lt;/td&gt;
&lt;td&gt;Show state of cells in laptop battery&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;#&lt;/td&gt;
&lt;td&gt;dmidecode -q | less&lt;/td&gt;
&lt;td&gt;Display SMBIOS/DMI information&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;#&lt;/td&gt;
&lt;td&gt;smartctl -A /dev/sda | grep Power_On_Hours&lt;/td&gt;
&lt;td&gt;How long has this disk (system) been powered on in total&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;#&lt;/td&gt;
&lt;td&gt;hdparm -i /dev/sda&lt;/td&gt;
&lt;td&gt;Show info about disk sda&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;#&lt;/td&gt;
&lt;td&gt;hdparm -tT /dev/sda&lt;/td&gt;
&lt;td&gt;Do a read speed test on disk sda&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;#&lt;/td&gt;
&lt;td&gt;badblocks -s /dev/sda&lt;/td&gt;
&lt;td&gt;Test for unreadable blocks on disk sda&lt;/td&gt;
&lt;/tr&gt;
&lt;tr id=&quot;interactive&quot;&gt;
&lt;td colspan=&quot;3&quot;&gt;&lt;strong&gt;interactive&lt;/strong&gt; (see also &lt;a href=&quot;http://www.pixelbeat.org/lkdb/&quot;&gt;linux keyboard shortcuts)&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;http://www.pixelbeat.org/lkdb/readline.html&quot;&gt;readline&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Line editor used by bash, python, bc, gnuplot, &amp;#8230;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;http://www.pixelbeat.org/lkdb/screen.html&quot;&gt;screen&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Virtual terminals with detach capability, &amp;#8230;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;http://www.pixelbeat.org/lkdb/mc.html&quot;&gt;mc&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Powerful file manager that can browse rpm, tar, ftp, ssh, &amp;#8230;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;http://www.pixelbeat.org/docs/web/access_log/analyzing.html&quot;&gt;gnuplot&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Interactive/scriptable graphing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;links&lt;/td&gt;
&lt;td&gt;Web browser&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;•&lt;/td&gt;
&lt;td&gt;xdg-open &lt;strong&gt;.&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;open a file or url with the registered desktop application&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/596885650/yahooblog/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/yahooblog/~7260371/596885650/5002429/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://blog.so8848.com/2011/12/55818.html/feed</wfw:commentRss><slash:comments>0</slash:comments><description>Command Description • apropos whatis Show commands pertinent to string. See also threadsafe • man -t man &amp;#124; ps2pdf &amp;#8211; &amp;#62; man.pdf make a pdf of a manual page which command Show full path name of command time command See how long a command takes • time cat Start stopwatch. Ctrl-d to stop. See also sw dir &lt;a href='http://blog.so8848.com/2011/12/55818.html'&gt;[...]&lt;/a&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/596885650/yahooblog/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/yahooblog/~7260371/596885650/5002429/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>Uncategorized</category><pubDate>Wed, 07 Dec 2011 13:30:39 +0800</pubDate><author>yezheng</author><comments>http://blog.so8848.com/2011/12/55818.html#comments</comments><guid isPermaLink="false">http://blog.zye.me/?p=55818</guid><dc:creator>yezheng</dc:creator><fs:srclink>http://blog.so8848.com/2011/12/55818.html</fs:srclink><fs:srcfeed>http://blog.so8848.com/feed</fs:srcfeed><fs:itemid>feedsky/yahooblog/~7260371/596885650/5002429</fs:itemid></item><item><title>Solr Error: A SPI class of type org.apache.lucene.index.codecs.Codec with name ‘Lucene40′ does not exist</title><link>http://item.feedsky.com/~feedsky/yahooblog/~7260371/596885651/5002429/1/item.html</link><content:encoded>&lt;p&gt;When you are testing Solr in Eclipse, you may encounter the problem that &amp;#8220;A SPI class of type org.apache.lucene.index.codecs.Codec with name &amp;#8216;Lucene40&amp;#8242; does not exist. You need to add the corresponding JAR file supporting this SPI to your classpath.The current classpath supports the following names: []&amp;#8221;&lt;/p&gt;
&lt;p&gt;The fast answer to tackle this problem is to add the lucene-core*.jar to the libaries of your project, and make sure that the file /META-INF/services/org.apache.lucene.index.codecs.Codec is included in lucene-core*.jar.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The problem is caused by the class of java.util.ServiceLoader used in&amp;nbsp;NamedSPILoader of Solr. When ServiceLoader creates a new service provider, it will extract some information from&amp;nbsp;/META-INF/services/org.apache.lucene.index.codecs.Codec. Therefore when you use build classes rather than the lucene-core*.jar file, the needed information can not be obtained. By now, I think you can handle this problem yourself.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For more information about How ServiceLoader work, please refer to:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://jcs.mobile-utopia.com/jcs/19273_ServiceLoader.java&quot;&gt;http://jcs.mobile-utopia.com/jcs/19273_ServiceLoader.java&lt;/a&gt;&amp;nbsp;In English&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://mxdxm.iteye.com/blog/1059300&quot;&gt;http://mxdxm.iteye.com/blog/1059300&lt;/a&gt;&amp;nbsp;In Chinese&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/596885651/yahooblog/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/yahooblog/~7260371/596885651/5002429/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://blog.so8848.com/2011/11/55863.html/feed</wfw:commentRss><slash:comments>0</slash:comments><description>When you are testing Solr in Eclipse, you may encounter the problem that &amp;#8220;A SPI class of type org.apache.lucene.index.codecs.Codec with name &amp;#8216;Lucene40&amp;#8242; does not exist. You need to add the corresponding JAR file supporting this SPI to your classpath.The current classpath supports the following names: []&amp;#8221; The fast answer to tackle this problem is to &lt;a href='http://blog.so8848.com/2011/11/55863.html'&gt;[...]&lt;/a&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/596885651/yahooblog/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/yahooblog/~7260371/596885651/5002429/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>Lucene40</category><category>IR</category><category>Java</category><category>lucene</category><category>Solr</category><pubDate>Mon, 14 Nov 2011 15:30:35 +0800</pubDate><author>yezheng</author><comments>http://blog.so8848.com/2011/11/55863.html#comments</comments><guid isPermaLink="false">http://blog.zye.me/2011/11/55863.html</guid><dc:creator>yezheng</dc:creator><fs:srclink>http://blog.so8848.com/2011/11/55863.html</fs:srclink><fs:srcfeed>http://blog.so8848.com/feed</fs:srcfeed><fs:itemid>feedsky/yahooblog/~7260371/596885651/5002429</fs:itemid></item><item><title>CIKM 2011 Keynote II: Justin Zobel on Biomedicine</title><link atom:type="text/html">http://www.searchenginecaffe.com/2011/10/cikm-2011-keynote-ii-justin-zobel-on.html</link><id xmlns="http://www.w3.org/2005/Atom" gr:original-id="tag:blogger.com,1999:blog-18315968.post-6850296420000159656">tag:google.com,2005:reader/item/d36f899fe062c731</id><content xmlns="http://www.w3.org/2005/Atom" xml:base="http://www.searchenginecaffe.com/" type="html">&lt;br&gt;&lt;table style=&quot;border-collapse:collapse;margin-bottom:1em;margin-left:0px;margin-right:0px;margin-top:1em&quot;&gt;&lt;tbody style=&quot;border-top-color:initial;border-top-style:none;border-top-width:initial&quot;&gt;&lt;tr&gt;&lt;td align=&quot;justify&quot; valign=&quot;top&quot;&gt;&lt;strong&gt;Data, Health, and Algorithmics: Computational Challenges for Biomedicine&lt;br&gt;by &lt;a href=&quot;http://ww2.cs.mu.oz.au/~jz/&quot;&gt;Justin Zobel&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;(I missed the first part of this talk)&lt;br&gt;&lt;br&gt;The Central Dogma&lt;br&gt;- DNA consts of sequence of four bases, A, C, G, T&lt;br&gt;- The concept of a gene is now uncertain&lt;br&gt;&lt;br&gt;SNP analysis (Nature 00)&lt;br&gt; - used PCA&lt;br&gt;&lt;br&gt;Revolution&lt;br&gt; - Read DNA directly&lt;br&gt; - $1000 by the end of 2012&lt;br&gt;&lt;br&gt;The data is erroful, incomplete, voluminous, ambiguous.&lt;br&gt;&lt;br&gt;Also, reads are not very random&lt;br&gt;&lt;br&gt;Within a few years there will be DNA databases of 10-100 terabases, which we will use to find matches to short read data&lt;br&gt;&lt;br&gt;&lt;br&gt;Challenge: Assembly&lt;br&gt; - Imagine a million copies of a phone book, a million pages long&lt;br&gt; - Shredded into tiny pieces, each no more than 20 or 30 characters&lt;br&gt; - 99.999% are thrown away.&lt;br&gt; - The task: reconstruct the phone book from the billion remaining pieces&lt;br&gt;&lt;br&gt;The Problem of assembling short reads.&lt;br&gt;&lt;br&gt;Genomes are a combinatorial minefield&lt;br&gt; - vast quantities of repeated material&lt;br&gt;&lt;br&gt;The genome is cheap, but the analysis is expensive&lt;br&gt;&lt;br&gt;de Bruijn graph&lt;br&gt; - Divide 7-base reads into kmers (3mers)&lt;br&gt; - each node is a kmer, each arc is an overlap&lt;br&gt;&lt;br&gt;The graph is about 4 terabytes, and it needs to be in memory.&lt;br&gt;&lt;br&gt;Succint 'Gossamer' representation&lt;br&gt; - fast access with simple index&lt;br&gt; - space down by a factor &amp;gt; 10&lt;br&gt; - cuts the storage down to 32 GB&lt;br&gt;&lt;br&gt;DNA dictionaries&lt;br&gt; - there is no grammar for DNA that would allow construction of a parser&lt;br&gt; - a dictionary of all possible tokens would be impossible large&lt;br&gt;&lt;br&gt;Dictionary - any representative string&lt;br&gt; -&amp;gt; solves the text compression problem for DBs&lt;br&gt;&lt;br&gt;Genetics for diagnosis&lt;br&gt; -&amp;gt; inference diagnosis based on symptons replaced by ones based on DNA analysis&lt;br&gt; -&amp;gt; drug effect and health outcome determined directly from historical health records&lt;br&gt; - Built to simplifly, improve, and automate bureaucratic decisions&lt;br&gt;&lt;br&gt;'Guardian Angel' clinical decisions&lt;br&gt; - Electronic health records analyzed on the fly to check whether a mistake is about to be made.&lt;br&gt;&lt;br&gt;Health at Home&lt;br&gt; -&amp;gt; health monitoring deeply embedded in our e-lifestyle activities&lt;br&gt; -&amp;gt; webcam that determines how well you are based on your skin&lt;br&gt; -&amp;gt; iphone app that tells if your drunk&lt;br&gt;&lt;br&gt;Computer Science vs heatlth research&lt;br&gt; - many algorithmic solutions are not biologically meaningful&lt;br&gt; - spend money on IT and the number of errors is decreased (It saves lives.)&lt;br&gt;&lt;br&gt;13 of the top 25 questions (Science mag July 2005) are about DNA&lt;br&gt;&lt;br&gt;The real way to have an impact on medicine is in the clinic -&amp;gt; text mining records.  Helping doctors make decisions.&lt;br&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/18315968-6850296420000159656?l=www.searchenginecaffe.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;</content><author xmlns="http://www.w3.org/2005/Atom"><name>jeff.dalton</name></author><source xmlns="http://www.w3.org/2005/Atom" gr:stream-id="feed/http://www.searchenginecaffe.com/feeds/posts/default"><id>tag:google.com,2005:reader/feed/http://www.searchenginecaffe.com/feeds/posts/default</id><title type="html">Jeff&amp;#39;s Search Engine Caffè</title><link rel="alternate" href="http://www.searchenginecaffe.com/" type="text/html"></link></source><content:encoded>&lt;br&gt;&lt;table style=&quot;border-collapse:collapse;margin-bottom:1em;margin-left:0px;margin-right:0px;margin-top:1em&quot;&gt;&lt;tbody style=&quot;border-top-color:initial;border-top-style:none;border-top-width:initial&quot;&gt;&lt;tr&gt;&lt;td align=&quot;justify&quot; valign=&quot;top&quot;&gt;&lt;strong&gt;Data, Health, and Algorithmics: Computational Challenges for Biomedicine&lt;br&gt;by &lt;a href=&quot;http://ww2.cs.mu.oz.au/~jz/&quot;&gt;Justin Zobel&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br&gt;(I missed the first part of this talk)&lt;br&gt;&lt;br&gt;The Central Dogma&lt;br&gt;- DNA consts of sequence of four bases, A, C, G, T&lt;br&gt;- The concept of a gene is now uncertain&lt;br&gt;&lt;br&gt;SNP analysis (Nature 00)&lt;br&gt; - used PCA&lt;br&gt;&lt;br&gt;Revolution&lt;br&gt; - Read DNA directly&lt;br&gt; - $1000 by the end of 2012&lt;br&gt;&lt;br&gt;The data is erroful, incomplete, voluminous, ambiguous.&lt;br&gt;&lt;br&gt;Also, reads are not very random&lt;br&gt;&lt;br&gt;Within a few years there will be DNA databases of 10-100 terabases, which we will use to find matches to short read data&lt;br&gt;&lt;br&gt;&lt;br&gt;Challenge: Assembly&lt;br&gt; - Imagine a million copies of a phone book, a million pages long&lt;br&gt; - Shredded into tiny pieces, each no more than 20 or 30 characters&lt;br&gt; - 99.999% are thrown away.&lt;br&gt; - The task: reconstruct the phone book from the billion remaining pieces&lt;br&gt;&lt;br&gt;The Problem of assembling short reads.&lt;br&gt;&lt;br&gt;Genomes are a combinatorial minefield&lt;br&gt; - vast quantities of repeated material&lt;br&gt;&lt;br&gt;The genome is cheap, but the analysis is expensive&lt;br&gt;&lt;br&gt;de Bruijn graph&lt;br&gt; - Divide 7-base reads into kmers (3mers)&lt;br&gt; - each node is a kmer, each arc is an overlap&lt;br&gt;&lt;br&gt;The graph is about 4 terabytes, and it needs to be in memory.&lt;br&gt;&lt;br&gt;Succint 'Gossamer' representation&lt;br&gt; - fast access with simple index&lt;br&gt; - space down by a factor &amp;gt; 10&lt;br&gt; - cuts the storage down to 32 GB&lt;br&gt;&lt;br&gt;DNA dictionaries&lt;br&gt; - there is no grammar for DNA that would allow construction of a parser&lt;br&gt; - a dictionary of all possible tokens would be impossible large&lt;br&gt;&lt;br&gt;Dictionary - any representative string&lt;br&gt; -&amp;gt; solves the text compression problem for DBs&lt;br&gt;&lt;br&gt;Genetics for diagnosis&lt;br&gt; -&amp;gt; inference diagnosis based on symptons replaced by ones based on DNA analysis&lt;br&gt; -&amp;gt; drug effect and health outcome determined directly from historical health records&lt;br&gt; - Built to simplifly, improve, and automate bureaucratic decisions&lt;br&gt;&lt;br&gt;'Guardian Angel' clinical decisions&lt;br&gt; - Electronic health records analyzed on the fly to check whether a mistake is about to be made.&lt;br&gt;&lt;br&gt;Health at Home&lt;br&gt; -&amp;gt; health monitoring deeply embedded in our e-lifestyle activities&lt;br&gt; -&amp;gt; webcam that determines how well you are based on your skin&lt;br&gt; -&amp;gt; iphone app that tells if your drunk&lt;br&gt;&lt;br&gt;Computer Science vs heatlth research&lt;br&gt; - many algorithmic solutions are not biologically meaningful&lt;br&gt; - spend money on IT and the number of errors is decreased (It saves lives.)&lt;br&gt;&lt;br&gt;13 of the top 25 questions (Science mag July 2005) are about DNA&lt;br&gt;&lt;br&gt;The real way to have an impact on medicine is in the clinic -&amp;gt; text mining records.  Helping doctors make decisions.&lt;br&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/18315968-6850296420000159656?l=www.searchenginecaffe.com&quot; alt=&quot;&quot;&gt;&lt;/div&gt;</content:encoded><pubDate>Wed, 26 Oct 2011 16:31:33 +0800</pubDate><guid isPermaLink="false">tag:google.com,2005:reader/item/d36f899fe062c731</guid><dc:creator>jeff.dalton</dc:creator><fs:srclink>http://www.searchenginecaffe.com/2011/10/cikm-2011-keynote-ii-justin-zobel-on.html</fs:srclink><fs:srcfeed>http://www.google.com/reader/public/atom/user/05267415691361832653/state/com.google/broadcast</fs:srcfeed><fs:itemid>feedsky/yahooblog/~8081258/596401120/5002429</fs:itemid><fs:burntype>mark</fs:burntype></item><item><title>连续跟iPhone 4s Siri求婚三次</title><link atom:type="text/html">http://www.dapenti.com/blog/more.asp?name=xilei&amp;id=51997</link><id xmlns="http://www.w3.org/2005/Atom" gr:original-id="">tag:google.com,2005:reader/item/9d71456262c15da7</id><author xmlns="http://www.w3.org/2005/Atom"><name>xilei</name></author><source xmlns="http://www.w3.org/2005/Atom" gr:stream-id="feed/http://www.dapenti.com/blog/rss2.asp?name=xilei"><id>tag:google.com,2005:reader/feed/http://www.dapenti.com/blog/rss2.asp?name=xilei</id><title type="html">喷嚏网----阅读、发现和分享：8小时外的健康生活！ 之 [铂程斋]</title><link rel="alternate" href="http://www.dapenti.com/blog/blog.asp?name=xilei" type="text/html"></link></source><description>&lt;p&gt;连续跟Siri求婚3次，看看Siri怎么回答 结果太强悍了！第一次Siri:”听起来很甜蜜，不过我还有什么可以帮你吗？“第二次Siri：”让我们只做朋友，好吗？“第三次Siri：”我的用户协议没有包括和你结婚，我很抱歉。”siri真是个散发着知性美的优雅女性啊~~&lt;/p&gt;
&lt;p&gt;
&lt;iframe src=&quot;http://reader.googleusercontent.com/reader/embediframe?src=http://www.tudou.com/v/GGfCv2mjLG0/%26autoPlay%3Dfalse/v.swf&amp;amp;width=480&amp;amp;height=400&quot; width=&quot;480&quot; height=&quot;400&quot;&gt;&lt;/iframe&gt;
&lt;/p&gt;
&lt;p&gt;链接：&lt;a href=&quot;http://www.tudou.com/programs/view/GGfCv2mjLG0/&quot;&gt;http://www.tudou.com/programs/view/GGfCv2mjLG0/&lt;/a&gt;&lt;/p&gt;&lt;br&gt;&lt;br&gt;打喷嚏链接：&lt;a href=&quot;http://www.dapenti.com/blog/more.asp?name=xilei&amp;amp;id=51997&quot;&gt;http://www.dapenti.com/blog/more.asp?name=xilei&amp;amp;id=51997&lt;/a&gt;
&lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://item.taobao.com/item.htm?id=13407924200&quot;&gt;&lt;img src=&quot;http://imgs.dapenti2.com:88/dapenti/BoRZvHNE/Sz8zu.jpg&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;br&gt;&lt;br&gt;用手机上&lt;a href=&quot;http://www.dapenti.com&quot;&gt;喷嚏网&lt;/a&gt;：m.dapenti.com        每天网络精华尽在【&lt;a href=&quot;http://www.dapenti.com/blog/blog.asp?subjectid=70&amp;amp;name=xilei&quot;&gt;喷嚏图卦&lt;/a&gt;】       &lt;a href=&quot;http://weibo.com/dapentizk&quot; title=&quot;喷嚏网官方新浪围脖&quot;&gt;喷嚏网官方新浪围脖&lt;/a&gt;</description><pubDate>Sun, 23 Oct 2011 21:02:00 +0800</pubDate><guid isPermaLink="false">tag:google.com,2005:reader/item/9d71456262c15da7</guid><dc:creator>xilei</dc:creator><fs:srclink>http://www.dapenti.com/blog/more.asp?name=xilei&amp;id=51997</fs:srclink><fs:srcfeed>http://www.google.com/reader/public/atom/user/05267415691361832653/state/com.google/broadcast</fs:srcfeed><fs:itemid>feedsky/yahooblog/~8081258/596401121/5002429</fs:itemid><fs:burntype>mark</fs:burntype></item><item><title>Introducing Crunch: Easy MapReduce Pipelines for Hadoop</title><link atom:type="text/html">http://www.cloudera.com/blog/2011/10/introducing-crunch/</link><id xmlns="http://www.w3.org/2005/Atom" gr:original-id="http://www.cloudera.com/?p=9165">tag:google.com,2005:reader/item/69bb5320c19ad33f</id><content xmlns="http://www.w3.org/2005/Atom" xml:base="http://www.cloudera.com/" type="html">&lt;p&gt;As a data scientist at Cloudera, I work with customers across a wide range of industries that use Hadoop to solve their business problems. Many of the solutions we create involve multi-stage pipelines of MapReduce jobs that join, clean, aggregate, and analyze enormous amounts of data. When working with log files or relational database tables, we use high-level tools like &lt;a href=&quot;http://pig.apache.org/&quot;&gt;Pig&lt;/a&gt; and &lt;a href=&quot;http://hive.apache.org/&quot;&gt;Hive&lt;/a&gt; for their convenient and powerful support for creating pipelines over structured and semi-structured records.&lt;/p&gt;
&lt;p&gt;As Hadoop has spread from web companies to other industries, the variety of data that is stored in HDFS has expanded dramatically. Hadoop clusters are being used to process satellite images, time series data, audio files, and seismograms. These formats are not a natural fit for the data schemas imposed by Pig and Hive, in the same way that structured binary data in a relational database can be a bit awkward to work with. For these use cases, we either end up writing large, custom libraries of user-defined functions in Pig or Hive, or simply give up on our high-level tools and go back to writing MapReduces in Java. Either of these options is a serious drain on developer productivity.&lt;/p&gt;
&lt;p&gt;Today, we’re pleased to introduce &lt;a href=&quot;http://github.com/cloudera/crunch&quot;&gt;Crunch&lt;/a&gt;, a Java library that aims to make writing, testing, and running MapReduce pipelines easy, efficient, and even fun. Crunch’s design is modeled after &lt;a href=&quot;http://dl.acm.org/citation.cfm?id=1806638&quot;&gt;Google’s FlumeJava&lt;/a&gt;, focusing on a small set of simple primitive operations and lightweight user-defined functions that can be combined to create complex, multi-stage pipelines. At runtime, Crunch compiles the pipeline into a sequence of MapReduce jobs and manages their execution.&lt;/p&gt;
&lt;h2&gt;Example&lt;/h2&gt;
&lt;p&gt;Let’s take a look at the classic WordCount MapReduce, written using Crunch:&lt;/p&gt;
&lt;pre&gt;
import com.cloudera.crunch.DoFn;
import com.cloudera.crunch.Emitter;
import com.cloudera.crunch.PCollection;
import com.cloudera.crunch.PTable;
import com.cloudera.crunch.Pipeline;
import com.cloudera.crunch.impl.mr.MRPipeline;
import com.cloudera.crunch.lib.Aggregate;
import com.cloudera.crunch.type.writable.Writables;

public class WordCount {
  public static void main(String[] args) throws Exception {
    // Create an object to coordinate pipeline creation and execution.
    Pipeline pipeline = new MRPipeline(WordCount.class);
    // Reference a given text file as a collection of Strings.
    PCollection&amp;lt;String&amp;gt; lines = pipeline.readTextFile(args[0]);

    // Define a function that splits each line in a PCollection of Strings into a
    // PCollection made up of the individual words in the file.
    PCollection&amp;lt;String&amp;gt; words = lines.parallelDo(new DoFn&amp;lt;String, String&amp;gt;() {
      public void process(String line, Emitter&amp;lt;String&amp;gt; emitter) {
        for (String word : line.split(&amp;quot;\\s+&amp;quot;)) {
          emitter.emit(word);
        }
      }
    }, Writables.strings()); // Indicates the serialization format

    // The Aggregate.count method applies a series of Crunch primitives and returns
    // a map of the unique words in the input PCollection to their counts.
    // Best of all, the count() function doesn&amp;#39;t need to know anything about
    // the kind of data stored in the input PCollection.
    PTable&amp;lt;String, Long&amp;gt; counts = Aggregate.count(words);

    // Instruct the pipeline to write the resulting counts to a text file.
    pipeline.writeTextFile(counts, args[1]);
    // Execute the pipeline as a MapReduce.
    pipeline.done();
  }
}&lt;/pre&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2&gt;Advantages&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;It’s just Java.&lt;/strong&gt; Crunch shares a core philosophical belief with Google’s FlumeJava: &lt;i&gt;novelty is the enemy of adoption&lt;/i&gt;. For developers, learning a Java library requires much less up-front investment than learning a new programming language. Crunch provides full access to the power of Java for writing functions, managing pipeline execution, and dynamically constructing new pipelines, obviating the need to switch back and forth between a data flow language and a real programming language.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Natural type system.&lt;/strong&gt; Crunch supports reading and writing data that is stored using Hadoop’s Writable format or &lt;a href=&quot;http://avro.apache.org/&quot;&gt;Apache Avro&lt;/a&gt; records. You do not need to write code that maps data stored in these formats into Crunch’s type system– they are supported natively. You can even mix and match Writable and Avro types within a single MapReduce: changing the &lt;code&gt;Writables.strings()&lt;/code&gt; call to &lt;code&gt;Avros.strings()&lt;/code&gt; in the WordCount example will run the MapReduce using Avro serialization instead of Writables.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A modular library released under the Apache License.&lt;/strong&gt; Experts in machine learning, text mining, and ETL can craft libraries using Crunch’s data model, and other developers can use those libraries to build custom pipelines that operate on their data. For example, Crunch can be used to create the glue code that converts raw data into the structured input that a machine learning algorithm expects, and Crunch will compile the glue code and the machine learning algorithm into a single MapReduce.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt; Future Work&lt;/h2&gt;
&lt;p&gt; We are releasing Crunch as a development project, not a product. We’re eager for developers to play with it and tell us what they like and what they dislike. You can get started with Crunch by downloading it from Cloudera’s github repository &lt;a href=&quot;https://github.com/cloudera/crunch&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We have tested the library on a number of our use cases, but there will be bugs and rough edges that we will work out in the coming months. We gladly welcome contributions from the Hadoop ecosystem to help us improve Crunch as we prepare it for submission to the Apache Incubator, especially around:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;More efficient MapReduce compilation, including cost-based optimization,&lt;/li&gt;
&lt;li&gt;Support for HBase and HCatalog as data sources/targets,&lt;/li&gt;
&lt;li&gt;Tools and examples that build Crunch pipelines in other JVM languages, such as Scala, JRuby, Clojure, and Jython.&lt;/li&gt;
&lt;/ul&gt;</content><author xmlns="http://www.w3.org/2005/Atom"><name>Josh Wills</name></author><source xmlns="http://www.w3.org/2005/Atom" gr:stream-id="feed/http://www.cloudera.com/feed/"><id>tag:google.com,2005:reader/feed/http://www.cloudera.com/feed/</id><title type="html">Cloudera</title><link rel="alternate" href="http://www.cloudera.com" type="text/html"></link></source><content:encoded>&lt;p&gt;As a data scientist at Cloudera, I work with customers across a wide range of industries that use Hadoop to solve their business problems. Many of the solutions we create involve multi-stage pipelines of MapReduce jobs that join, clean, aggregate, and analyze enormous amounts of data. When working with log files or relational database tables, we use high-level tools like &lt;a href=&quot;http://pig.apache.org/&quot;&gt;Pig&lt;/a&gt; and &lt;a href=&quot;http://hive.apache.org/&quot;&gt;Hive&lt;/a&gt; for their convenient and powerful support for creating pipelines over structured and semi-structured records.&lt;/p&gt;
&lt;p&gt;As Hadoop has spread from web companies to other industries, the variety of data that is stored in HDFS has expanded dramatically. Hadoop clusters are being used to process satellite images, time series data, audio files, and seismograms. These formats are not a natural fit for the data schemas imposed by Pig and Hive, in the same way that structured binary data in a relational database can be a bit awkward to work with. For these use cases, we either end up writing large, custom libraries of user-defined functions in Pig or Hive, or simply give up on our high-level tools and go back to writing MapReduces in Java. Either of these options is a serious drain on developer productivity.&lt;/p&gt;
&lt;p&gt;Today, we’re pleased to introduce &lt;a href=&quot;http://github.com/cloudera/crunch&quot;&gt;Crunch&lt;/a&gt;, a Java library that aims to make writing, testing, and running MapReduce pipelines easy, efficient, and even fun. Crunch’s design is modeled after &lt;a href=&quot;http://dl.acm.org/citation.cfm?id=1806638&quot;&gt;Google’s FlumeJava&lt;/a&gt;, focusing on a small set of simple primitive operations and lightweight user-defined functions that can be combined to create complex, multi-stage pipelines. At runtime, Crunch compiles the pipeline into a sequence of MapReduce jobs and manages their execution.&lt;/p&gt;
&lt;h2&gt;Example&lt;/h2&gt;
&lt;p&gt;Let’s take a look at the classic WordCount MapReduce, written using Crunch:&lt;/p&gt;
&lt;pre&gt;
import com.cloudera.crunch.DoFn;
import com.cloudera.crunch.Emitter;
import com.cloudera.crunch.PCollection;
import com.cloudera.crunch.PTable;
import com.cloudera.crunch.Pipeline;
import com.cloudera.crunch.impl.mr.MRPipeline;
import com.cloudera.crunch.lib.Aggregate;
import com.cloudera.crunch.type.writable.Writables;

public class WordCount {
  public static void main(String[] args) throws Exception {
    // Create an object to coordinate pipeline creation and execution.
    Pipeline pipeline = new MRPipeline(WordCount.class);
    // Reference a given text file as a collection of Strings.
    PCollection&amp;lt;String&amp;gt; lines = pipeline.readTextFile(args[0]);

    // Define a function that splits each line in a PCollection of Strings into a
    // PCollection made up of the individual words in the file.
    PCollection&amp;lt;String&amp;gt; words = lines.parallelDo(new DoFn&amp;lt;String, String&amp;gt;() {
      public void process(String line, Emitter&amp;lt;String&amp;gt; emitter) {
        for (String word : line.split(&amp;quot;\\s+&amp;quot;)) {
          emitter.emit(word);
        }
      }
    }, Writables.strings()); // Indicates the serialization format

    // The Aggregate.count method applies a series of Crunch primitives and returns
    // a map of the unique words in the input PCollection to their counts.
    // Best of all, the count() function doesn&amp;#39;t need to know anything about
    // the kind of data stored in the input PCollection.
    PTable&amp;lt;String, Long&amp;gt; counts = Aggregate.count(words);

    // Instruct the pipeline to write the resulting counts to a text file.
    pipeline.writeTextFile(counts, args[1]);
    // Execute the pipeline as a MapReduce.
    pipeline.done();
  }
}&lt;/pre&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2&gt;Advantages&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;It’s just Java.&lt;/strong&gt; Crunch shares a core philosophical belief with Google’s FlumeJava: &lt;i&gt;novelty is the enemy of adoption&lt;/i&gt;. For developers, learning a Java library requires much less up-front investment than learning a new programming language. Crunch provides full access to the power of Java for writing functions, managing pipeline execution, and dynamically constructing new pipelines, obviating the need to switch back and forth between a data flow language and a real programming language.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Natural type system.&lt;/strong&gt; Crunch supports reading and writing data that is stored using Hadoop’s Writable format or &lt;a href=&quot;http://avro.apache.org/&quot;&gt;Apache Avro&lt;/a&gt; records. You do not need to write code that maps data stored in these formats into Crunch’s type system– they are supported natively. You can even mix and match Writable and Avro types within a single MapReduce: changing the &lt;code&gt;Writables.strings()&lt;/code&gt; call to &lt;code&gt;Avros.strings()&lt;/code&gt; in the WordCount example will run the MapReduce using Avro serialization instead of Writables.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A modular library released under the Apache License.&lt;/strong&gt; Experts in machine learning, text mining, and ETL can craft libraries using Crunch’s data model, and other developers can use those libraries to build custom pipelines that operate on their data. For example, Crunch can be used to create the glue code that converts raw data into the structured input that a machine learning algorithm expects, and Crunch will compile the glue code and the machine learning algorithm into a single MapReduce.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt; Future Work&lt;/h2&gt;
&lt;p&gt; We are releasing Crunch as a development project, not a product. We’re eager for developers to play with it and tell us what they like and what they dislike. You can get started with Crunch by downloading it from Cloudera’s github repository &lt;a href=&quot;https://github.com/cloudera/crunch&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We have tested the library on a number of our use cases, but there will be bugs and rough edges that we will work out in the coming months. We gladly welcome contributions from the Hadoop ecosystem to help us improve Crunch as we prepare it for submission to the Apache Incubator, especially around:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;More efficient MapReduce compilation, including cost-based optimization,&lt;/li&gt;
&lt;li&gt;Support for HBase and HCatalog as data sources/targets,&lt;/li&gt;
&lt;li&gt;Tools and examples that build Crunch pipelines in other JVM languages, such as Scala, JRuby, Clojure, and Jython.&lt;/li&gt;
&lt;/ul&gt;</content:encoded><category>Avro</category><category>MapReduce</category><category>general</category><category>hadoop</category><pubDate>Tue, 11 Oct 2011 01:05:44 +0800</pubDate><guid isPermaLink="false">tag:google.com,2005:reader/item/69bb5320c19ad33f</guid><dc:creator>Josh Wills</dc:creator><fs:srclink>http://www.cloudera.com/blog/2011/10/introducing-crunch/</fs:srclink><fs:srcfeed>http://www.google.com/reader/public/atom/user/05267415691361832653/state/com.google/broadcast</fs:srcfeed><fs:itemid>feedsky/yahooblog/~8081258/596401122/5002429</fs:itemid><fs:burntype>mark</fs:burntype></item><item><title>Apache Sqoop – Overview</title><link atom:type="text/html">http://www.cloudera.com/blog/2011/10/apache-sqoop-overview/</link><id xmlns="http://www.w3.org/2005/Atom" gr:original-id="http://www.cloudera.com/?p=9138">tag:google.com,2005:reader/item/dd554784a170a815</id><content xmlns="http://www.w3.org/2005/Atom" xml:base="http://www.cloudera.com/" type="html">&lt;p&gt;&lt;em&gt;This blog was originally posted on the Apache Blog: &lt;a href=&quot;https://blogs.apache.org/sqoop/entry/apache_sqoop_overview&quot;&gt;https://blogs.apache.org/sqoop/entry/apache_sqoop_overview&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Using Hadoop for analytics and data processing requires loading data into clusters and processing it in conjunction with other data that often resides in production databases across the enterprise. Loading bulk data into Hadoop from production systems or accessing it from map reduce applications running on large clusters can be a challenging task. Users must consider details like ensuring consistency of data, the consumption of production system resources, data preparation for provisioning downstream pipeline. Transferring data using scripts is inefficient and time consuming. Directly accessing data residing on external systems from within the map reduce applications complicates applications and exposes the production system to the risk of excessive load originating from cluster nodes.&lt;/p&gt;
&lt;p&gt;This is where Apache Sqoop fits in. Apache Sqoop is currently undergoing incubation at Apache Software Foundation. More information on this project can be found at &lt;a title=&quot;Apache Sqoop&quot; href=&quot;http://incubator.apache.org/sqoop&quot;&gt;http://incubator.apache.org/sqoop&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Sqoop allows easy import and export of data from structured data stores such as relational databases, enterprise data warehouses, and NoSQL systems. Using Sqoop, you can provision the data from external system on to HDFS, and populate tables in Hive and HBase. Sqoop integrates with Oozie, allowing you to schedule and automate import and export tasks. Sqoop uses a connector based architecture which supports plugins that provide connectivity to new external systems.&lt;/p&gt;
&lt;p&gt;What happens underneath the covers when you run Sqoop is very straightforward. The dataset being transferred is sliced up into different partitions and a map-only job is launched with individual mappers responsible for transferring a slice of this dataset. Each record of the data is handled in a type safe manner since Sqoop uses the database metadata to infer the data types.&lt;/p&gt;
&lt;p&gt;In the rest of this post we will walk through an example that shows the various ways you can use Sqoop. The goal of this post is to give an overview of Sqoop operation without going into much detail or advanced functionality.&lt;/p&gt;
&lt;h2&gt;Importing Data&lt;/h2&gt;
&lt;p&gt;The following command is used to import all data from a table called ORDERS from a MySQL database:&lt;/p&gt;
&lt;pre style=&quot;padding-bottom:10px&quot;&gt;---
$ &lt;strong&gt;sqoop import --connect jdbc:mysql://localhost/acmedb \
    --table ORDERS --username test --password ****&lt;/strong&gt;
---&lt;/pre&gt;
&lt;p&gt;In this command the various options specified are as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;import:&lt;/em&gt; This is the sub-command that instructs Sqoop to initiate an import.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;–connect &amp;lt;connect string&amp;gt;, –username &amp;lt;user name&amp;gt;, –password&lt;br&gt;
&amp;lt;password&amp;gt;:&lt;/em&gt; These are connection parameters that are used to connect with the database. This is no different from the connection parameters that you use when connecting to the database via a JDBC connection.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;–table &amp;lt;table name&amp;gt;:&lt;/em&gt; This parameter specifies the table which will be imported.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The import is done in two steps as depicted in Figure 1 below. In the first Step Sqoop introspects the database to gather the necessary metadata for the data being imported. The second step is a map-only Hadoop job that Sqoop submits to the cluster. It is this job that does the actual data transfer using the metadata captured in the previous step.&lt;/p&gt;
&lt;p style=&quot;text-align:center&quot;&gt;&lt;img src=&quot;https://blogs.apache.org/sqoop/mediaresource/d76fa176-1331-4af3-95cf-ae6a0068c306&quot; alt=&quot;Figure 1: Sqoop Import Overview&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;text-align:center&quot;&gt;&lt;strong&gt;Figure 1: Sqoop Import Overview&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The imported data is saved in a directory on HDFS based on the table being imported. As is the case with most aspects of Sqoop operation, the user can specify any alternative directory where the files should be populated.&lt;/p&gt;
&lt;p&gt;By default these files contain comma delimited fields, with new lines separating different records. You can easily override the format in which data is copied over by explicitly specifying the field separator and record terminator characters.&lt;/p&gt;
&lt;p&gt;Sqoop also supports different data formats for importing data. For example, you can easily import data in Avro data format by simply specifying the option &lt;em&gt;–as-avrodatafile&lt;/em&gt; with the import command.&lt;/p&gt;
&lt;p&gt;There are many other options that Sqoop provides which can be used to further tune the import operation to suit your specific requirements.&lt;/p&gt;
&lt;h2&gt;Importing Data into Hive&lt;/h2&gt;
&lt;p&gt;In most cases, importing data into Hive is the same as running the import task and then using Hive to create and load a certain table or partition. Doing this manually requires that you know the correct type mapping between the data and other details like the serialization format and delimiters. Sqoop takes care of populating the Hive metastore with the appropriate metadata for the table and also invokes the necessary commands to load the table or partition as the case may be. All of this is done by simply specifying the option –hive-import with the import command.&lt;/p&gt;
&lt;pre style=&quot;padding-bottom:10px&quot;&gt;----
&lt;span style=&quot;font-family:&amp;#39;courier new&amp;#39;,courier,monospace&quot;&gt;$ sqoop import --connect jdbc:mysql://localhost/acmedb \
      --table ORDERS --username test --password **** &lt;strong&gt;--hive-import&lt;/strong&gt;&lt;/span&gt;
----&lt;/pre&gt;
&lt;p&gt;When you run a Hive import, Sqoop converts the data from the native datatypes within the external datastore into the corresponding types within Hive. Sqoop automatically chooses the native delimiter set used by Hive. If the data being imported has new line or other Hive delimiter characters in it, Sqoop allows you to remove such characters and get the data correctly populated for consumption in Hive.&lt;/p&gt;
&lt;p&gt;Once the import is complete, you can see and operate on the table just like any other table in Hive.&lt;/p&gt;
&lt;h2&gt;Importing Data into HBase&lt;/h2&gt;
&lt;p&gt;You can use Sqoop to populate data in a particular column family within the HBase table. Much like the Hive import, this can be done by specifying the additional options that relate to the HBase table and column family being populated. All data imported into HBase is converted to their string representation and inserted as UTF-8 bytes.&lt;/p&gt;
&lt;pre style=&quot;padding-bottom:10px&quot;&gt;----
&lt;span style=&quot;font-family:&amp;#39;courier new&amp;#39;,courier,monospace&quot;&gt;$ sqoop import --connect jdbc:mysql://localhost/acmedb \
        --table ORDERS --username test --password **** \
        &lt;strong&gt;--hbase-create-table --hbase-table ORDERS --column-family mysql&lt;/strong&gt;&lt;/span&gt;
----&lt;/pre&gt;
&lt;p&gt;In this command the various options specified are as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;–hbase-create-table:&lt;/em&gt; This option instructs Sqoop to create the HBase table.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;–hbase-table:&lt;/em&gt; This option specifies the table name to use.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;–column-family:&lt;/em&gt; This option specifies the column family name to use.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The rest of the options are the same as that for regular import operation.&lt;/p&gt;
&lt;h2&gt;Exporting Data&lt;/h2&gt;
&lt;p&gt;In some cases data processed by Hadoop pipelines may be needed in production systems to help run additional critical business functions. Sqoop can be used to export such data into external datastores as necessary. Continuing our example from above – if data generated by the pipeline on Hadoop corresponded to the ORDERS table in a database somewhere, you could populate it using the following command:&lt;/p&gt;
&lt;pre style=&quot;padding-bottom:10px&quot;&gt;----
$ sqoop &lt;strong&gt;export&lt;/strong&gt; --connect jdbc:mysql://localhost/acmedb \
        --table ORDERS --username test --password **** \
        &lt;strong&gt;--export-dir /user/arvind/ORDERS&lt;/strong&gt;
----&lt;/pre&gt;
&lt;p&gt;In this command the various options specified are as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;export:&lt;/em&gt; This is the sub-command that instructs Sqoop to initiate an export.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;–connect &amp;lt;connect string&amp;gt;, –username &amp;lt;user name&amp;gt;, –password&lt;br&gt;
&amp;lt;password&amp;gt;:&lt;/em&gt; These are connection parameters that are used to connect with the database. This is no different from the connection parameters that you use when connecting to the database via a JDBC connection.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;–table &amp;lt;table name&amp;gt;:&lt;/em&gt; This parameter specifies the table which will be populated.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;–export-dir &amp;lt;directory path&amp;gt;:&lt;/em&gt; This is the directory from which data will be exported.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Export is done in two steps as depicted in Figure 2. The first step is to introspect the database for metadata, followed by the second step of transferring the data. Sqoop divides the input dataset into splits and then uses individual map tasks to push the splits to the database. Each map task performs this transfer over many transactions in order to ensure optimal throughput and minimal resource utilization.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blogs.apache.org/sqoop/mediaresource/12624986-9e30-430e-a0c7-e12176548f6d&quot; alt=&quot;Figure 2: Sqoop Export Overview&quot;&gt;&lt;/p&gt;
&lt;strong&gt;Figure 2: Sqoop Export Overview&lt;/strong&gt;
&lt;p&gt;Some connectors support staging tables that help isolate production tables from possible corruption in case of job failures due to any reason. Staging tables are first populated by the map tasks and then merged into the target table once all of the data has been delivered it.&lt;/p&gt;
&lt;h2&gt;Sqoop Connectors&lt;/h2&gt;
&lt;p&gt;Using specialized connectors, Sqoop can connect with external systems that have optimized import and export facilities, or do not support native JDBC. Connectors are plugin components based on Sqoop’s extension framework and can be added to any existing Sqoop installation. Once a connector is installed, Sqoop can use it to efficiently transfer data between Hadoop and the external store supported by the connector.&lt;/p&gt;
&lt;p&gt;By default Sqoop includes connectors for various popular databases such as MySQL, PostgreSQL, Oracle, SQL Server and DB2. It also includes fast-path connectors for MySQL and PostgreSQL databases. Fast-path connectors are specialized connectors that use database specific batch tools to transfer data with high throughput. Sqoop also includes a generic JDBC connector that can be used to connect to any database that is accessible via JDBC.&lt;/p&gt;
&lt;p&gt;Apart from the built-in connectors, many companies have developed their own connectors that can be plugged into Sqoop. These range from specialized connectors for enterprise data warehouse systems to NoSQL datastores.&lt;/p&gt;
&lt;h2&gt;Wrapping Up&lt;/h2&gt;
&lt;p&gt;In this post you saw how easy it is to transfer large datasets between Hadoop and external datastores such as relational databases. Beyond this, Sqoop offers many advance features such as different data formats, compression, working with queries instead of tables etc. We encourage you to try out Sqoop and give us your feedback.&lt;/p&gt;
&lt;p&gt;More information regarding Sqoop can be found at:&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size:small&quot;&gt;Project Website: &lt;a title=&quot;Apache Sqoop&quot; href=&quot;http://incubator.apache.org/sqoop&quot;&gt;http://incubator.apache.org/sqoop&lt;/a&gt;&lt;br&gt;
Wiki: &lt;a title=&quot;Sqoop Wiki&quot; href=&quot;https://cwiki.apache.org/confluence/display/SQOOP&quot;&gt;https://cwiki.apache.org/confluence/display/SQOOP&lt;/a&gt;&lt;br&gt;
Project Status:  &lt;a title=&quot;Sqoop Project Status&quot; href=&quot;http://incubator.apache.org/projects/sqoop.html&quot;&gt;http://incubator.apache.org/projects/sqoop.html&lt;/a&gt;&lt;br&gt;
Mailing Lists: &lt;a title=&quot;Sqoop Mailing Lists&quot; href=&quot;https://cwiki.apache.org/confluence/display/SQOOP/Mailing+Lists&quot;&gt;https://cwiki.apache.org/confluence/display/SQOOP/Mailing+Lists&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</content><author xmlns="http://www.w3.org/2005/Atom"><name>Arvind Prabhakar</name></author><source xmlns="http://www.w3.org/2005/Atom" gr:stream-id="feed/http://www.cloudera.com/feed/"><id>tag:google.com,2005:reader/feed/http://www.cloudera.com/feed/</id><title type="html">Cloudera</title><link rel="alternate" href="http://www.cloudera.com" type="text/html"></link></source><content:encoded>&lt;p&gt;&lt;em&gt;This blog was originally posted on the Apache Blog: &lt;a href=&quot;https://blogs.apache.org/sqoop/entry/apache_sqoop_overview&quot;&gt;https://blogs.apache.org/sqoop/entry/apache_sqoop_overview&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Using Hadoop for analytics and data processing requires loading data into clusters and processing it in conjunction with other data that often resides in production databases across the enterprise. Loading bulk data into Hadoop from production systems or accessing it from map reduce applications running on large clusters can be a challenging task. Users must consider details like ensuring consistency of data, the consumption of production system resources, data preparation for provisioning downstream pipeline. Transferring data using scripts is inefficient and time consuming. Directly accessing data residing on external systems from within the map reduce applications complicates applications and exposes the production system to the risk of excessive load originating from cluster nodes.&lt;/p&gt;
&lt;p&gt;This is where Apache Sqoop fits in. Apache Sqoop is currently undergoing incubation at Apache Software Foundation. More information on this project can be found at &lt;a title=&quot;Apache Sqoop&quot; href=&quot;http://incubator.apache.org/sqoop&quot;&gt;http://incubator.apache.org/sqoop&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Sqoop allows easy import and export of data from structured data stores such as relational databases, enterprise data warehouses, and NoSQL systems. Using Sqoop, you can provision the data from external system on to HDFS, and populate tables in Hive and HBase. Sqoop integrates with Oozie, allowing you to schedule and automate import and export tasks. Sqoop uses a connector based architecture which supports plugins that provide connectivity to new external systems.&lt;/p&gt;
&lt;p&gt;What happens underneath the covers when you run Sqoop is very straightforward. The dataset being transferred is sliced up into different partitions and a map-only job is launched with individual mappers responsible for transferring a slice of this dataset. Each record of the data is handled in a type safe manner since Sqoop uses the database metadata to infer the data types.&lt;/p&gt;
&lt;p&gt;In the rest of this post we will walk through an example that shows the various ways you can use Sqoop. The goal of this post is to give an overview of Sqoop operation without going into much detail or advanced functionality.&lt;/p&gt;
&lt;h2&gt;Importing Data&lt;/h2&gt;
&lt;p&gt;The following command is used to import all data from a table called ORDERS from a MySQL database:&lt;/p&gt;
&lt;pre style=&quot;padding-bottom:10px&quot;&gt;---
$ &lt;strong&gt;sqoop import --connect jdbc:mysql://localhost/acmedb \
    --table ORDERS --username test --password ****&lt;/strong&gt;
---&lt;/pre&gt;
&lt;p&gt;In this command the various options specified are as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;import:&lt;/em&gt; This is the sub-command that instructs Sqoop to initiate an import.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;–connect &amp;lt;connect string&amp;gt;, –username &amp;lt;user name&amp;gt;, –password&lt;br&gt;
&amp;lt;password&amp;gt;:&lt;/em&gt; These are connection parameters that are used to connect with the database. This is no different from the connection parameters that you use when connecting to the database via a JDBC connection.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;–table &amp;lt;table name&amp;gt;:&lt;/em&gt; This parameter specifies the table which will be imported.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The import is done in two steps as depicted in Figure 1 below. In the first Step Sqoop introspects the database to gather the necessary metadata for the data being imported. The second step is a map-only Hadoop job that Sqoop submits to the cluster. It is this job that does the actual data transfer using the metadata captured in the previous step.&lt;/p&gt;
&lt;p style=&quot;text-align:center&quot;&gt;&lt;img src=&quot;https://blogs.apache.org/sqoop/mediaresource/d76fa176-1331-4af3-95cf-ae6a0068c306&quot; alt=&quot;Figure 1: Sqoop Import Overview&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;text-align:center&quot;&gt;&lt;strong&gt;Figure 1: Sqoop Import Overview&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The imported data is saved in a directory on HDFS based on the table being imported. As is the case with most aspects of Sqoop operation, the user can specify any alternative directory where the files should be populated.&lt;/p&gt;
&lt;p&gt;By default these files contain comma delimited fields, with new lines separating different records. You can easily override the format in which data is copied over by explicitly specifying the field separator and record terminator characters.&lt;/p&gt;
&lt;p&gt;Sqoop also supports different data formats for importing data. For example, you can easily import data in Avro data format by simply specifying the option &lt;em&gt;–as-avrodatafile&lt;/em&gt; with the import command.&lt;/p&gt;
&lt;p&gt;There are many other options that Sqoop provides which can be used to further tune the import operation to suit your specific requirements.&lt;/p&gt;
&lt;h2&gt;Importing Data into Hive&lt;/h2&gt;
&lt;p&gt;In most cases, importing data into Hive is the same as running the import task and then using Hive to create and load a certain table or partition. Doing this manually requires that you know the correct type mapping between the data and other details like the serialization format and delimiters. Sqoop takes care of populating the Hive metastore with the appropriate metadata for the table and also invokes the necessary commands to load the table or partition as the case may be. All of this is done by simply specifying the option –hive-import with the import command.&lt;/p&gt;
&lt;pre style=&quot;padding-bottom:10px&quot;&gt;----
&lt;span style=&quot;font-family:&amp;#39;courier new&amp;#39;,courier,monospace&quot;&gt;$ sqoop import --connect jdbc:mysql://localhost/acmedb \
      --table ORDERS --username test --password **** &lt;strong&gt;--hive-import&lt;/strong&gt;&lt;/span&gt;
----&lt;/pre&gt;
&lt;p&gt;When you run a Hive import, Sqoop converts the data from the native datatypes within the external datastore into the corresponding types within Hive. Sqoop automatically chooses the native delimiter set used by Hive. If the data being imported has new line or other Hive delimiter characters in it, Sqoop allows you to remove such characters and get the data correctly populated for consumption in Hive.&lt;/p&gt;
&lt;p&gt;Once the import is complete, you can see and operate on the table just like any other table in Hive.&lt;/p&gt;
&lt;h2&gt;Importing Data into HBase&lt;/h2&gt;
&lt;p&gt;You can use Sqoop to populate data in a particular column family within the HBase table. Much like the Hive import, this can be done by specifying the additional options that relate to the HBase table and column family being populated. All data imported into HBase is converted to their string representation and inserted as UTF-8 bytes.&lt;/p&gt;
&lt;pre style=&quot;padding-bottom:10px&quot;&gt;----
&lt;span style=&quot;font-family:&amp;#39;courier new&amp;#39;,courier,monospace&quot;&gt;$ sqoop import --connect jdbc:mysql://localhost/acmedb \
        --table ORDERS --username test --password **** \
        &lt;strong&gt;--hbase-create-table --hbase-table ORDERS --column-family mysql&lt;/strong&gt;&lt;/span&gt;
----&lt;/pre&gt;
&lt;p&gt;In this command the various options specified are as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;–hbase-create-table:&lt;/em&gt; This option instructs Sqoop to create the HBase table.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;–hbase-table:&lt;/em&gt; This option specifies the table name to use.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;–column-family:&lt;/em&gt; This option specifies the column family name to use.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The rest of the options are the same as that for regular import operation.&lt;/p&gt;
&lt;h2&gt;Exporting Data&lt;/h2&gt;
&lt;p&gt;In some cases data processed by Hadoop pipelines may be needed in production systems to help run additional critical business functions. Sqoop can be used to export such data into external datastores as necessary. Continuing our example from above – if data generated by the pipeline on Hadoop corresponded to the ORDERS table in a database somewhere, you could populate it using the following command:&lt;/p&gt;
&lt;pre style=&quot;padding-bottom:10px&quot;&gt;----
$ sqoop &lt;strong&gt;export&lt;/strong&gt; --connect jdbc:mysql://localhost/acmedb \
        --table ORDERS --username test --password **** \
        &lt;strong&gt;--export-dir /user/arvind/ORDERS&lt;/strong&gt;
----&lt;/pre&gt;
&lt;p&gt;In this command the various options specified are as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;export:&lt;/em&gt; This is the sub-command that instructs Sqoop to initiate an export.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;–connect &amp;lt;connect string&amp;gt;, –username &amp;lt;user name&amp;gt;, –password&lt;br&gt;
&amp;lt;password&amp;gt;:&lt;/em&gt; These are connection parameters that are used to connect with the database. This is no different from the connection parameters that you use when connecting to the database via a JDBC connection.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;–table &amp;lt;table name&amp;gt;:&lt;/em&gt; This parameter specifies the table which will be populated.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;–export-dir &amp;lt;directory path&amp;gt;:&lt;/em&gt; This is the directory from which data will be exported.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Export is done in two steps as depicted in Figure 2. The first step is to introspect the database for metadata, followed by the second step of transferring the data. Sqoop divides the input dataset into splits and then uses individual map tasks to push the splits to the database. Each map task performs this transfer over many transactions in order to ensure optimal throughput and minimal resource utilization.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://blogs.apache.org/sqoop/mediaresource/12624986-9e30-430e-a0c7-e12176548f6d&quot; alt=&quot;Figure 2: Sqoop Export Overview&quot;&gt;&lt;/p&gt;
&lt;strong&gt;Figure 2: Sqoop Export Overview&lt;/strong&gt;
&lt;p&gt;Some connectors support staging tables that help isolate production tables from possible corruption in case of job failures due to any reason. Staging tables are first populated by the map tasks and then merged into the target table once all of the data has been delivered it.&lt;/p&gt;
&lt;h2&gt;Sqoop Connectors&lt;/h2&gt;
&lt;p&gt;Using specialized connectors, Sqoop can connect with external systems that have optimized import and export facilities, or do not support native JDBC. Connectors are plugin components based on Sqoop’s extension framework and can be added to any existing Sqoop installation. Once a connector is installed, Sqoop can use it to efficiently transfer data between Hadoop and the external store supported by the connector.&lt;/p&gt;
&lt;p&gt;By default Sqoop includes connectors for various popular databases such as MySQL, PostgreSQL, Oracle, SQL Server and DB2. It also includes fast-path connectors for MySQL and PostgreSQL databases. Fast-path connectors are specialized connectors that use database specific batch tools to transfer data with high throughput. Sqoop also includes a generic JDBC connector that can be used to connect to any database that is accessible via JDBC.&lt;/p&gt;
&lt;p&gt;Apart from the built-in connectors, many companies have developed their own connectors that can be plugged into Sqoop. These range from specialized connectors for enterprise data warehouse systems to NoSQL datastores.&lt;/p&gt;
&lt;h2&gt;Wrapping Up&lt;/h2&gt;
&lt;p&gt;In this post you saw how easy it is to transfer large datasets between Hadoop and external datastores such as relational databases. Beyond this, Sqoop offers many advance features such as different data formats, compression, working with queries instead of tables etc. We encourage you to try out Sqoop and give us your feedback.&lt;/p&gt;
&lt;p&gt;More information regarding Sqoop can be found at:&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size:small&quot;&gt;Project Website: &lt;a title=&quot;Apache Sqoop&quot; href=&quot;http://incubator.apache.org/sqoop&quot;&gt;http://incubator.apache.org/sqoop&lt;/a&gt;&lt;br&gt;
Wiki: &lt;a title=&quot;Sqoop Wiki&quot; href=&quot;https://cwiki.apache.org/confluence/display/SQOOP&quot;&gt;https://cwiki.apache.org/confluence/display/SQOOP&lt;/a&gt;&lt;br&gt;
Project Status:  &lt;a title=&quot;Sqoop Project Status&quot; href=&quot;http://incubator.apache.org/projects/sqoop.html&quot;&gt;http://incubator.apache.org/projects/sqoop.html&lt;/a&gt;&lt;br&gt;
Mailing Lists: &lt;a title=&quot;Sqoop Mailing Lists&quot; href=&quot;https://cwiki.apache.org/confluence/display/SQOOP/Mailing+Lists&quot;&gt;https://cwiki.apache.org/confluence/display/SQOOP/Mailing+Lists&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</content:encoded><category>Avro</category><category>CDH</category><category>Connector</category><category>HBase</category><category>community</category><category>data collection</category><category>general</category><category>hadoop</category><category>hive</category><category>oozie</category><category>sqoop</category><category>Apache Sqoop</category><category>Hadoop connector</category><pubDate>Fri, 07 Oct 2011 02:49:27 +0800</pubDate><guid isPermaLink="false">tag:google.com,2005:reader/item/dd554784a170a815</guid><dc:creator>Arvind Prabhakar</dc:creator><fs:srclink>http://www.cloudera.com/blog/2011/10/apache-sqoop-overview/</fs:srclink><fs:srcfeed>http://www.google.com/reader/public/atom/user/05267415691361832653/state/com.google/broadcast</fs:srcfeed><fs:itemid>feedsky/yahooblog/~8081258/596401123/5002429</fs:itemid><fs:burntype>mark</fs:burntype></item><item><title>汉字编码问题合集–整理</title><link>http://item.feedsky.com/~feedsky/yahooblog/~7260371/596885652/5002429/1/item.html</link><content:encoded>&lt;h3 class=&quot;post-title entry-title&quot;&gt;&lt;a href=&quot;http://gblog.5yiso.cn/2007/11/blog-post_09.html&quot;&gt;&lt;br /&gt;
&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;span style=&quot;font-family: Verdana;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;汉字编码问题&lt;br /&gt;
下面是搜集的多篇关于汉字编码问题文章的合集，相信你的问题一定包含在其中，如果没有请留言，一起把这方面的内容补充全。&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;一、汉字编码的种类&lt;br /&gt;
汉字编码中现在主要用到的有三类，包括GBK，GB2312和Big5。&lt;br /&gt;
1、 GB2312又称国标码，由国家标准总局发布，1981年5月1日实施，通行于大陆。新加坡等地也使用此编码。它是一个简化字的编码规范，当然也包括其他 的符号、字母、日文假名等，共7445个图形字符，其中汉字占6763个。我们平时说6768个汉字，实际上里边有5个编码为空白，所以总共有6763个 汉字。&lt;br /&gt;
GB2312规定&amp;#8221;对任意一个图形字符都采用两个字节表示，每个字节均采用七位编码表示&amp;#8221;，习惯上称第一个字节为&amp;#8221;高字节&amp;#8221;，第二个字节 为&amp;#8221;低字节&amp;#8221;。GB2312中汉字的编码范围为，第一字节0xB0-0xF7(对应十进制为176-247)，第二个字节0xA0-0xFE（对应十进制 为160-254）。&lt;br /&gt;
GB2312将代码表分为94个区，对应第一字节（0xa1-0xfe）；每个区94个位（0xa1-0xfe），对应第二 字节，两个字节的值分别为区号值和位号值加32（2OH），因此也称为区位码。01-09区为符号、数字区，16-87区为汉字区（0xb0- 0xf7），10-15区、88-94区是有待进一步标准化的空白区。&lt;br /&gt;
2、Big5又称大五码，主要为香港与台湾使用，即是一个繁体字编码。每个 汉字由两个字节构成，第一个字节的范围从0X81－0XFE（即129-255），共126种。第二个字节的范围不连续，分别为0X40－0X7E（即 64-126），0XA1－0XFE（即161-254），共157种。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;3、GBK是GB2312的扩展，是向上兼容的，因此 GB2312 中的汉字的编码与GBK中汉字的相同。另外，GBK中还包含繁体字的编码，它与Big5编码之间的关系我还没有弄明白，好像是不一致的。GBK中每个汉字 仍然包含两个字节，第一个字节的范围是0&amp;#215;81-0xFE（即129-254），第二个字节的范围是0&amp;#215;40-0xFE（即64-254）。GBK中有码 位23940个，包含汉字21003个。&lt;/p&gt;
&lt;p&gt;表1 汉字编码范围&lt;/p&gt;
&lt;p&gt;名称    |       第一字节          |           第二字节&lt;br /&gt;
&amp;#8212;&amp;#8212;&amp;#8211;|&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;-|&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&lt;br /&gt;
GB2312  |   0xB0-0xF7(176-247)    |    0xA0-0xFE（160-254）&lt;br /&gt;
&amp;#8212;&amp;#8212;&amp;#8211;|&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;-|&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;-&lt;br /&gt;
GBK0    |  x81-0xFE（129-254）    |   0&amp;#215;40-0xFE（64-254）&lt;br /&gt;
&amp;#8212;&amp;#8212;&amp;#8211;|&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;-|&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;-&lt;br /&gt;
Big5    |   0&amp;#215;81-0xFE（129-255）  |   0&amp;#215;40-0x7E（64-126），&lt;br /&gt;
|                         |    0xA1－0xFE（161-254）&lt;br /&gt;
&amp;#8212;&amp;#8212;&amp;#8211;|&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;-|&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&lt;br /&gt;
二、对汉字进行hash&lt;br /&gt;
为了处理汉字的方便，在查找汉字的时候，我们通常会用到hash的方法，那怎么来确定一个汉字位置呢？这就和每种编码的排列有关了，这里主要给出一种hash函数的策略。&lt;br /&gt;
对于GB2312编码，设输入的汉字为GBword，我们可以采用公式(C1-176)*94 + (C2-161)确定GBindex。其中，C1表示第一字节，C2表示第二字节。具体如下：&lt;br /&gt;
GBindex = ((unsigned char)GBword.at(0)-176)*94 + (unsigned char)GBword.at(1) &amp;#8211; 161;&lt;br /&gt;
之所以用unsigned char类型，是因为char是一个字节，如果用unsigend int，因为int是4个字节的，所以会造成扩展，导致错误。&lt;br /&gt;
对于GBK编码，设输入的汉字为GBKword，则可以采用公式   index=(ch1-0&amp;#215;81)*190+(ch2-0&amp;#215;40)-(ch2/128)，其中ch1是第一字节，ch2是第二字节。&lt;br /&gt;
具体的，&lt;br /&gt;
GBKindex = ((unsigned char)GBKword[0]-129)*190 +&lt;br /&gt;
((unsigned char)GBKword[1]-64) &amp;#8211; (unsigned char)GBKword[1]/128;&lt;/p&gt;
&lt;p&gt;三、怎样判断一个汉字的是什么编码&lt;br /&gt;
直接根据汉字的编码范围判断，对于GB2312和GBK可用下面两个程序实现。&lt;br /&gt;
1、判断是否是GB2312&lt;br /&gt;
bool isGBCode(const string&amp;amp; strIn)&lt;br /&gt;
{&lt;br /&gt;
unsigned char ch1;&lt;br /&gt;
unsigned char ch2;&lt;/p&gt;
&lt;p&gt;if (strIn.size() &amp;gt;= 2)&lt;br /&gt;
{&lt;br /&gt;
ch1 = (unsigned char)strIn.at(0);&lt;br /&gt;
ch2 = (unsigned char)strIn.at(1);&lt;br /&gt;
if (ch1&amp;gt;=176 &amp;amp;&amp;amp; ch1&amp;lt;=247 &amp;amp;&amp;amp;ch2&amp;gt;=160 &amp;amp;&amp;amp; ch2&amp;lt;=254)&lt;br /&gt;
return true;&lt;br /&gt;
else return false;&lt;br /&gt;
}&lt;br /&gt;
else return false;&lt;br /&gt;
}&lt;br /&gt;
2、判断是否是GBK编码&lt;br /&gt;
bool isGBKCode(const string&amp;amp; strIn)&lt;br /&gt;
{&lt;br /&gt;
unsigned char ch1;&lt;br /&gt;
unsigned char ch2;&lt;/p&gt;
&lt;p&gt;if (strIn.size() &amp;gt;= 2)&lt;br /&gt;
{&lt;br /&gt;
ch1 = (unsigned char)strIn.at(0);&lt;br /&gt;
ch2 = (unsigned char)strIn.at(1);&lt;br /&gt;
if (ch1&amp;gt;=129 &amp;amp;&amp;amp; ch1&amp;lt;=254 &amp;amp;&amp;amp;ch2&amp;gt;=64 &amp;amp;&amp;amp; ch2&amp;lt;=254)&lt;br /&gt;
return true;&lt;br /&gt;
else return false;&lt;br /&gt;
}&lt;br /&gt;
else return false;&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;3、对于Big5&lt;br /&gt;
它 的范围为：高字节从0xA0到0xFE，低字节从0&amp;#215;40到0x7E，和0xA1到0xFE两部分。判断一个汉字是否是BIG5编码，可以如上对字符的编 码范围判断即可。如何定位呢？那么也想象所有编码排列为一个二维坐标，纵坐标是高字节，横坐标是低字节。这样一行上的汉字个数：(0x7E-0&amp;#215;40+ 1)+(0xFE-0xA1+1)＝157。那么定位算法分两块，为:&lt;/p&gt;
&lt;p&gt;if 0&amp;#215;40&amp;lt;=ch2&amp;lt;=0x7E: #is big5 char&lt;br /&gt;
index=((ch1-0xA1)*157+(ch2-0&amp;#215;40))*2&lt;br /&gt;
elif 0xA1&amp;lt;=ch2&amp;lt;=0xFE: #is big5 char&lt;br /&gt;
index=((ch1-0xA1)*157+(ch2-0xA1+63))*2&lt;/p&gt;
&lt;p&gt;对于第二块，计算偏移量时因为有两块数值，所以在计算后面一段值时，不要忘了前面还有一段值。0x7E-0&amp;#215;40+1=63。&lt;/p&gt;
&lt;p&gt;四、如果判断一个字符是西文字符还是中文字符&lt;br /&gt;
大家知道西文字符主要是指ASCII码，它用一个字节表示。且这个字符转换成数字之后，该数字是大于0的，而汉字是两个字节的，第一个字节的转化为数字之后应该是小于0的，因此可以根据每个字节转化为数字之后是否小于0，判断它是否是汉字。&lt;br /&gt;
例如，设输入字为strin，则，&lt;br /&gt;
If (strin.at(0) &amp;lt; 0)&lt;br /&gt;
cout &amp;lt;&amp;lt; &amp;#8220;是汉字&amp;#8221; &amp;lt;&amp;lt; endl;&lt;br /&gt;
else cout &amp;lt;&amp;lt; &amp;#8220;不是汉字&amp;#8221; &amp;lt;&amp;lt; endl;&lt;br /&gt;
五、下载GBK编码表（见附件）&lt;br /&gt;
下载GB2312编码表见下面的回帖&lt;/p&gt;
&lt;p&gt;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8211;&lt;br /&gt;
另一些与编码相关的文章：&lt;br /&gt;
1、GB码和BIG5码的互换技术&lt;br /&gt;
&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;-&lt;br /&gt;
中文与英文用ASCII码一个字节表示不同，它使用两个字节来表示。事实上，在文本文件中保存的就是每个汉字对应的两个字节编码，而显示问题由中文操作系统自动解决。&lt;br /&gt;
汉字编码并不统一，我们使用的是GB码，而台湾地区使用的是BIG5码。BIG5码文件中保存的是汉字相应的BIG5编码，GB码文件中保存的是汉字相应的GB编码。所以转换工作的关键是有一个记录每个BIG5编码对应GB编码的码表文件。&lt;br /&gt;
GB码编码规则是这样的：每个汉字由两个字节构成，第一个字节的范围从0XA1－0XFE，共96种。第二个字节的范围分别为0XA1－0XFE，共96种。利用这两个字节共可定义出 96 * 96＝8836种汉字。实际共有6763个汉字。&lt;br /&gt;
BIG5码编码规则是这样的：每个汉字由两个字节构成，第一个字节的范围从0X81－0XFE，共126种。第二个字节的范围分别为0X40－0X7E， 0XA1－0XFE，共157种。也就是说，利用这两个字节共可定义出 126 * 157＝19782种汉字。这些汉字的一部分是我们常用到的，如一、丁，这些字我们称为常用字，其BIG5码的范围为0XA440－0XC671，共 5401个。较不常用的字，如滥、调，我们称为次常用字，范围为 0XC940－0XF9FE，共7652个，剩下的便是一些特殊字符。&lt;br /&gt;
制作码表文件的原理是这样的：首先将所有的GB编码写入一个文件，然后，使用具有GB码到BIG5码转换功能的软件，如UCDOS下的CONVERT.EXE，将文件转换为BIG5码文件，即得到码表文件。&lt;br /&gt;
下面的程序可将全部国标码写入文件gb.txt(以下全部程序用foxpro书写，可很容易的转换成其他语言)&lt;br /&gt;
fp = fopen(&amp;#8220;gb.txt&amp;#8221;,2)&lt;br /&gt;
for i=161 to 247&lt;br /&gt;
for j=161 to 254&lt;br /&gt;
=fwrite(fp,chr(i)+chr(j))&lt;br /&gt;
next&lt;br /&gt;
=fwrite(fp,chr(13)+chr(10))&lt;br /&gt;
next&lt;br /&gt;
=fwrite(fp,chr(26))&lt;br /&gt;
=fclose(fp)&lt;/p&gt;
&lt;p&gt;文件的组织形式：行对应编码的第一字节，列对应编码的第二字节。使用时请注意编码的偏移量，如汉字&amp;#8221;啊&amp;#8221;GB编码0xb1a1第一字节0xb1(177) 第二字节0xa1(161)所以他应该在文件的第(177-161=16)行第((161-161)*2=0)列。&lt;br /&gt;
运行CONVERT.EXE将gb.txt转换成BIG5码的文件，这样就可得到按GB码组织的BIG5码表文件big5.txt。反之亦可得到按BIG5码组织的GB码表文件。&lt;/p&gt;
&lt;p&gt;转换的思路是这样的：(用foxpro书写)&lt;br /&gt;
首先将码表文件装入数组&lt;br /&gt;
fp = fopen(&amp;#8220;big5.txt&amp;#8221;)&lt;br /&gt;
i = 0&lt;br /&gt;
do while feof(fp)&lt;br /&gt;
i = i+1&lt;br /&gt;
dime dict&lt;br /&gt;
dict = fgets(fp)&lt;br /&gt;
enddo&lt;br /&gt;
=fclose(fp)&lt;br /&gt;
其次将待转换的文本装入变量&lt;br /&gt;
create cursor temp (mm m)&lt;br /&gt;
append blank&lt;br /&gt;
append memo mm from textfilename&lt;br /&gt;
text = mm&lt;br /&gt;
然后扫描文本，替换所有的GB编码&lt;br /&gt;
temp = &amp;#8220;&amp;#8221;&lt;br /&gt;
i = 1&lt;br /&gt;
do while i &amp;lt; len(text)&lt;br /&gt;
ch = substr(text,i,1)&lt;br /&gt;
if isascii(ch)   &amp;amp;&amp;amp; 若是ASCII码&lt;br /&gt;
temp = temp+ch&lt;br /&gt;
i = i+1&lt;br /&gt;
else&lt;br /&gt;
ch1 = substr(text,i+1,1)&lt;br /&gt;
big5 = substr(dict[asc(ch)-161+1],(asc(ch1)-161)*2+1,2)&lt;br /&gt;
temp = temp+big5&lt;br /&gt;
i = i+2&lt;br /&gt;
endif&lt;br /&gt;
enddo&lt;br /&gt;
最后将在temp中得到转换后的文本&lt;/p&gt;
&lt;p&gt;需要注意的是，在foxpro中数组指针是以1开始，substr函数的起始位&amp;gt;=1。&lt;/p&gt;
&lt;p&gt;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&lt;br /&gt;
一、GB2312-80介绍&lt;br /&gt;
GB2312码是中华人民共和国国家汉字信息交换用编码，全称《信息交换用汉字编码字符集&amp;#8211;基本集》，由国家标准总局发布，1981年5月1日实施，通行于大陆。新加坡等地也使用此编码。&lt;br /&gt;
GB2312 收录简化汉字及符号、字母、日文假名等共7445个图形字符，其中汉字占6763个。GB2312规定&amp;#8221;对任意一个图形字符都采用两个字节表示，每个字节 均采用七位编码表示&amp;#8221;，习惯上称第一个字节为&amp;#8221;高字节&amp;#8221;，第二个字节为&amp;#8221;低字节&amp;#8221;。GB2312-80包含了大部分常用的一、二级汉字，和9区的符号。该 字符集是几乎所有的中文系统和国际化的软件都支持的中文字符集，这也是最基本的中文字符集。其编码范围是高位0xa1－0xfe，低位也是0xa1- 0xfe；汉字从0xb0a1开始，结束于0xf7fe。&lt;br /&gt;
GB2312将代码表分为94个区，对应第一字节（0xa1-0xfe）；每个区94个 位（0xa1-0xfe），对应第二字节，两个字节的值分别为区号值和位号值加32（2OH），因此也称为区位码。01-09区为符号、数字区，16- 87区为汉字区（0xb0-0xf7），10-15区、88-94区是有待进一步标准化的空白区。GB2312将收录的汉字分成两级：第一级是常用汉字计 3755个，置于16-55区，按汉语拼音字母/笔形顺序排列；第二级汉字是次常用汉字计3008个，置于56-87区，按部首/笔画顺序排列。故而 GB2312最多能表示6763个汉字。&lt;br /&gt;
GB2312的编码范围为2121H-777EH，与ASCII有重叠，通行方法是将GB码两个字节的最高位置1以示区别。&lt;br /&gt;
二、GB2312-80的扩展&lt;/p&gt;
&lt;p&gt;GBK是GB2312-80的扩展，是向上兼容的。它包含了20902个汉字，其编码范围是0&amp;#215;8140-0xfefe，剔除高位0&amp;#215;80的字位。其所有字符都可以一对一映射到Unicode2.0。&lt;br /&gt;
GB18030-2000(GBK2K)在GBK的基础上进一步扩展了汉字，增加了藏、蒙等少数民族的字形。GBK2K从根本上解决了字位不够，字形不足的问题。它有几个特点：&lt;br /&gt;
它并没有确定所有的字形，只是规定了编码范围，留待以后扩充。&lt;br /&gt;
编码是变长的，其二字节部分与GBK兼容；四字节部分是扩充的字形、字位，其编码范围是首字节0&amp;#215;81-0xfe、二字节0&amp;#215;30-0&amp;#215;39、三字节0&amp;#215;81-0xfe、四字节0&amp;#215;30-0&amp;#215;39。&lt;br /&gt;
它的推广是分阶段的，首先要求实现的是能够完全映射到Unicode3.0标准的所有字形。&lt;br /&gt;
它是国家标准，是强制性的。&lt;br /&gt;
现在还没有任何一个操作系统或软件实现了GBK2K的支持，这是现阶段和将来汉化的工作内容。&lt;/p&gt;
&lt;p&gt;三、Unicode编码&lt;/p&gt;
&lt;p&gt;国 际标准组织于1984年4月成立ISO/IECJTC1/SC2/WG2工作组，针对各国文字、符号进行统一性编码。1991年美国跨国公司成立 UnicodeConsortium，并于1991年10月与WG2达成协议，采用同一编码字集。目前Unicode是采用16位编码体系，其字符集内容 与ISO10646的BMP（BasicMultilingualPlane）相同。Unicode于1992年6月通过DIS （DrafInternationalStandard），目前版本V2.0于1996公布，内容包含符号6811个，汉字20902个，韩文拼音 11172个，造字区6400个，保留20249个，共计65534个。&lt;br /&gt;
随着国际互联网的迅速发展，要求进行数据交换的需求越来越大，不同的编码体系越来越成为信息交换的障碍，而且多种语言共存的文档不断增多，单靠代码页已很难解决这些问题，于是UNICODE应运而生。&lt;br /&gt;
UNICODE 有双重含义，首先UNICODE是对国际标准ISO/IEC10646编码的一种称谓（ISO/IEC10646是一个国际标准，亦称大字符集，它是 ISO于1993年颁布的一项重要国际标准，其宗旨是全球所有文种统一编码），另外它又是由美国的HP、Microsoft、IBM、Apple等大企业 组成的联盟集团的名称，成立该集团的宗旨就是要推进多文种的统一编码。&lt;br /&gt;
UNICODE同现在流行的代码页最显著不同点在于：UNICODE是两字 节的全编码，对于ASCII字符它也使用两字节表示。代码页是通过高字节的取值范围来确定是ASCII字符，还是汉字的高字节。如果发生数据损坏，某处内 容破坏，则会引起其后汉字的混乱。UNICODE则一律使用两个字节表示一个字符，最明显的好处是它简化了汉字的处理过程。&lt;br /&gt;
UNICODE使用平面来描述编码空间，每个平面分为256行，256列，相对于两字节编码的高低两个字节。&lt;br /&gt;
UNICODE的第一个平面，称为BasicMultilingualPlane（基本多文种平面），简称BMP，由于BMP仅用两个字节表示，所以倍受青睐。&lt;/p&gt;
&lt;p&gt;一些相关的网页：&lt;br /&gt;
GBK代码表： &lt;a href=&quot;http://www.haiyan.com/steelk/navigator/ref/gbk/gbindex2.htm&quot;&gt;http://www.haiyan.com/steelk/navigator/ref/gbk/gbindex2.htm&lt;/a&gt;&lt;br /&gt;
GBK 汉字内码扩展规范：&lt;a href=&quot;http://www.haizhuedu.net/no-weiyischool/hzdwzx/xxzy/xxzy-kj/xxzy-xx/xkjs2-8/HAIZI/GBK.htm&quot;&gt;http://www.haizhuedu.net/no-weiyischool/hzdwzx/xxzy/xxzy-kj/xxzy-xx/xkjs2-8/HAIZI/GBK.htm&lt;/a&gt;&lt;br /&gt;
下载GB2312编码表，见附件&lt;br /&gt;
&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8211;&lt;br /&gt;
谈谈Unicode编码，简要解释UCS、UTF、BMP、BOM等名词&lt;br /&gt;
这是一篇程序员写给程序员的趣味读物。所谓趣味是指可以比较轻松地了解一些原来不清楚的概念，增进知识，类似于打RPG游戏的升级。整理这篇文章的动机是两个问题：&lt;br /&gt;
问题一：&lt;br /&gt;
使用Windows记事本的&amp;#8221;另存为&amp;#8221;，可以在GBK、Unicode、Unicode big endian和UTF-8这几种编码方式间相互转换。同样是txt文件，Windows是怎样识别编码方式的呢？&lt;/p&gt;
&lt;p&gt;我 很早前就发现Unicode、Unicode big endian和UTF-8编码的txt文件的开头会多出几个字节，分别是FF、FE（Unicode）,FE、FF（Unicode big endian）,EF、BB、BF（UTF-8）。但这些标记是基于什么标准呢？&lt;/p&gt;
&lt;p&gt;问题二：&lt;br /&gt;
最近在网上看到一个 ConvertUTF.c，实现了UTF-32、UTF-16和UTF-8这三种编码方式的相互转换。对于Unicode(UCS2)、GBK、UTF- 8这些编码方式，我原来就了解。但这个程序让我有些糊涂，想不起来UTF-16和UCS2有什么关系。&lt;br /&gt;
查了查相关资料，总算将这些问题弄清楚了，顺带也了解了一些Unicode的细节。写成一篇文章，送给有过类似疑问的朋友。本文在写作时尽量做到通俗易懂，但要求读者知道什么是字节，什么是十六进制。&lt;/p&gt;
&lt;p&gt;0、big endian和little endian&lt;br /&gt;
big endian和little endian是CPU处理多字节数的不同方式。例如&amp;#8221;汉&amp;#8221;字的Unicode编码是6C49。那么写到文件里时，究竟是将6C写在前面，还是将49写在前 面？如果将6C写在前面，就是big endian。如果将49写在前面，就是little endian。&lt;/p&gt;
&lt;p&gt;&amp;#8220;endian&amp;#8221;这个词出自《格列佛游记》。小人国的内战就源于吃鸡蛋时是究竟从大头(Big-Endian)敲开还是从小头(Little-Endian)敲开，由此曾发生过六次叛乱，一个皇帝送了命，另一个丢了王位。&lt;/p&gt;
&lt;p&gt;我们一般将endian翻译成&amp;#8221;字节序&amp;#8221;，将big endian和little endian称作&amp;#8221;大尾&amp;#8221;和&amp;#8221;小尾&amp;#8221;。&lt;/p&gt;
&lt;p&gt;1、字符编码、内码，顺带介绍汉字编码&lt;br /&gt;
字符必须编码后才能被计算机处理。计算机使用的缺省编码方式就是计算机的内码。早期的计算机使用7位的ASCII编码，为了处理汉字，程序员设计了用于简体中文的GB2312和用于繁体中文的big5。&lt;/p&gt;
&lt;p&gt;GB2312(1980年)一共收录了7445个字符，包括6763个汉字和682个其它符号。汉字区的内码范围高字节从B0-F7，低字节从A1-FE，占用的码位是72*94=6768。其中有5个空位是D7FA-D7FE。&lt;/p&gt;
&lt;p&gt;GB2312支持的汉字太少。1995年的汉字扩展规范GBK1.0收录了21886个符号，它分为汉字区和图形符号区。汉字区包括21003个字符。&lt;/p&gt;
&lt;p&gt;从ASCII、 GB2312到GBK，这些编码方法是向下兼容的，即同一个字符在这些方案中总是有相同的编码，后面的标准支持更多的字符。在这些编码中，英文和中文可以 统一地处理。区分中文编码的方法是高字节的最高位不为0。按照程序员的称呼，GB2312、GBK都属于双字节字符集 (DBCS)。&lt;/p&gt;
&lt;p&gt;2000 年的GB18030是取代GBK1.0的正式国家标准。该标准收录了27484个汉字，同时还收录了藏文、蒙文、维吾尔文等主要的少数民族文字。从汉字字 汇上说，GB18030在GB13000.1的20902个汉字的基础上增加了CJK扩展A的6582个汉字（Unicode码0&amp;#215;3400- 0x4db5），一共收录了27484个汉字。&lt;/p&gt;
&lt;p&gt;CJK就是中日韩的意思。Unicode为了节省码位，将中日韩三国语言中的文字统一编码。GB13000.1就是ISO/IEC 10646-1的中文版，相当于Unicode 1.1。&lt;/p&gt;
&lt;p&gt;GB18030 的编码采用单字节、双字节和4字节方案。其中单字节、双字节和GBK是完全兼容的。4字节编码的码位就是收录了CJK扩展A的6582个汉字。例如： UCS的0&amp;#215;3400在GB18030中的编码应该是8139EF30，UCS的0&amp;#215;3401在GB18030中的编码应该是8139EF31。&lt;/p&gt;
&lt;p&gt;微软提供了GB18030的升级包，但这个升级包只是提供了一套支持CJK扩展A的6582个汉字的新字体：新宋体-18030，并不改变内码。Windows 的内码仍然是GBK。&lt;/p&gt;
&lt;p&gt;这里还有一些细节：&lt;/p&gt;
&lt;p&gt;GB2312的原文还是区位码，从区位码到内码，需要在高字节和低字节上分别加上A0。&lt;/p&gt;
&lt;p&gt;对 于任何字符编码，编码单元的顺序是由编码方案指定的，与endian无关。例如GBK的编码单元是字节，用两个字节表示一个汉字。这两个字节的顺序是固定 的，不受CPU字节序的影响。UTF-16的编码单元是word（双字节），word之间的顺序是编码方案指定的，word内部的字节排列才会受到 endian的影响。后面还会介绍UTF-16。&lt;/p&gt;
&lt;p&gt;GB2312的两个字节的最高位都是1。但符合这个条件的码位只有 128*128=16384个。所以GBK和GB18030的低字节最高位都可能不是1。不过这不影响DBCS字符流的解析：在读取DBCS字符流时，只 要遇到高位为1的字节，就可以将下两个字节作为一个双字节编码，而不用管低字节的高位是什么。&lt;/p&gt;
&lt;p&gt;2、Unicode、UCS和UTF&lt;br /&gt;
前面提到从ASCII、GB2312、GBK到GB18030的编码方法是向下兼容的。而Unicode只与ASCII兼容（更准确地说，是与ISO-8859-1兼容），与GB码不兼容。例如&amp;#8221;汉&amp;#8221;字的Unicode编码是6C49，而GB码是BABA。&lt;/p&gt;
&lt;p&gt;Unicode 也是一种字符编码方法，不过它是由国际组织设计，可以容纳全世界所有语言文字的编码方案。Unicode的学名是&amp;#8221;Universal Multiple-Octet Coded Character Set&amp;#8221;，简称为UCS。UCS可以看作是&amp;#8221;Unicode Character Set&amp;#8221;的缩写。&lt;/p&gt;
&lt;p&gt;根据维基百科全书(&lt;a href=&quot;http://zh.wikipedia.org/wiki/&quot;&gt;http://zh.wikipedia.org/wiki/&lt;/a&gt;)的记载：历史上存在两个试图独立设计Unicode的组织，即国际标准化组织（ISO）和一个软件制造商的协会（unicode.org）。ISO开发了ISO 10646项目，Unicode协会开发了Unicode项目。&lt;/p&gt;
&lt;p&gt;在1991年前后，双方都认识到世界不需要两个不兼容的字符集。于是它们开始合并双方的工作成果，并为创立一个单一编码表而协同工作。从Unicode2.0开始，Unicode项目采用了与ISO 10646-1相同的字库和字码。&lt;/p&gt;
&lt;p&gt;目前两个项目仍都存在，并独立地公布各自的标准。Unicode协会现在的最新版本是2005年的Unicode 4.1.0。ISO的最新标准是ISO 10646-3:2003。&lt;/p&gt;
&lt;p&gt;UCS 只是规定如何编码，并没有规定如何传输、保存这个编码。例如&amp;#8221;汉&amp;#8221;字的UCS编码是6C49，我可以用4个ascii数字来传输、保存这个编码；也可以用 utf-8编码:3个连续的字节E6 B1 89来表示它。关键在于通信双方都要认可。UTF-8、UTF-7、UTF-16都是被广泛接受的方案。UTF-8的一个特别的好处是它与ISO- 8859-1完全兼容。UTF是&amp;#8221;UCS Transformation format&amp;#8221;的缩写。&lt;/p&gt;
&lt;p&gt;IETF的RFC2781和 RFC3629以RFC的一贯风格，清晰、明快又不失严谨地描述了UTF-16和UTF-8的编码方法。我总是记不得IETF是Internet Engineering Task Force的缩写。但IETF负责维护的RFC是Internet上一切规范的基础。&lt;/p&gt;
&lt;p&gt;2.1、内码和code page&lt;br /&gt;
目前Windows的内核已经支持Unicode字符集，这样在内核上可以支持全世界所有的语言文字。但是由于现有的大量程序和文档都采用了某种特定语言的编码，例如GBK，Windows不可能不支持现有的编码，而全部改用Unicode。&lt;/p&gt;
&lt;p&gt;Windows使用代码页(code page)来适应各个国家和地区。code page可以被理解为前面提到的内码。GBK对应的code page是CP936。&lt;/p&gt;
&lt;p&gt;微软也为GB18030定义了code page：CP54936。但是由于GB18030有一部分4字节编码，而Windows的代码页只支持单字节和双字节编码，所以这个code page是无法真正使用的。&lt;/p&gt;
&lt;p&gt;3、UCS-2、UCS-4、BMP&lt;br /&gt;
UCS有两种格式：UCS-2和UCS-4。顾名思义，UCS-2就是用两个字节编码，UCS-4就是用4个字节（实际上只用了31位，最高位必须为0）编码。下面让我们做一些简单的数学游戏：&lt;/p&gt;
&lt;p&gt;UCS-2有2^16=65536个码位，UCS-4有2^31=2147483648个码位。&lt;/p&gt;
&lt;p&gt;UCS -4根据最高位为0的最高字节分成2^7=128个group。每个group再根据次高字节分为256个plane。每个plane根据第3个字节分为 256行 (rows)，每行包含256个cells。当然同一行的cells只是最后一个字节不同，其余都相同。&lt;/p&gt;
&lt;p&gt;group 0的plane 0被称作Basic Multilingual Plane, 即BMP。或者说UCS-4中，高两个字节为0的码位被称作BMP。&lt;/p&gt;
&lt;p&gt;将UCS-4的BMP去掉前面的两个零字节就得到了UCS-2。在UCS-2的两个字节前加上两个零字节，就得到了UCS-4的BMP。而目前的UCS-4规范中还没有任何字符被分配在BMP之外。&lt;/p&gt;
&lt;p&gt;4、UTF编码&lt;/p&gt;
&lt;p&gt;UTF-8就是以8位为单元对UCS进行编码。从UCS-2到UTF-8的编码方式如下：&lt;/p&gt;
&lt;p&gt;UCS-2编码(16进制) UTF-8 字节流(二进制)&lt;br /&gt;
0000 &amp;#8211; 007F 0xxxxxxx&lt;br /&gt;
0080 &amp;#8211; 07FF 110xxxxx 10xxxxxx&lt;br /&gt;
0800 &amp;#8211; FFFF 1110xxxx 10xxxxxx 10xxxxxx&lt;/p&gt;
&lt;p&gt;例 如&amp;#8221;汉&amp;#8221;字的Unicode编码是6C49。6C49在0800-FFFF之间，所以肯定要用3字节模板了：1110xxxx 10xxxxxx 10xxxxxx。将6C49写成二进制是：0110 110001 001001， 用这个比特流依次代替模板中的x，得到：11100110 10110001 10001001，即E6 B1 89。&lt;/p&gt;
&lt;p&gt;读者可以用记事本测试一下我们的编码是否正确。需要注意，UltraEdit在打开utf-8编码的文本文件时会自动转换为UTF-16，可能产生混淆。你可以在设置中关掉这个选项。更好的工具是Hex Workshop。&lt;/p&gt;
&lt;p&gt;UTF -16以16位为单元对UCS进行编码。对于小于0&amp;#215;10000的UCS码，UTF-16编码就等于UCS码对应的16位无符号整数。对于不小于 0&amp;#215;10000的UCS码，定义了一个算法。不过由于实际使用的UCS2，或者UCS4的BMP必然小于0&amp;#215;10000，所以就目前而言，可以认为UTF -16和UCS-2基本相同。但UCS-2只是一个编码方案，UTF-16却要用于实际的传输，所以就不得不考虑字节序的问题。&lt;/p&gt;
&lt;p&gt;5、UTF的字节序和BOM&lt;br /&gt;
UTF -8以字节为编码单元，没有字节序的问题。UTF-16以两个字节为编码单元，在解释一个UTF-16文本前，首先要弄清楚每个编码单元的字节序。例如 &amp;#8220;奎&amp;#8221;的Unicode编码是594E，&amp;#8221;乙&amp;#8221;的Unicode编码是4E59。如果我们收到UTF-16字节流&amp;#8221;594E&amp;#8221;，那么这是&amp;#8221;奎&amp;#8221;还是 &amp;#8220;乙&amp;#8221;？&lt;/p&gt;
&lt;p&gt;Unicode规范中推荐的标记字节顺序的方法是BOM。BOM不是&amp;#8221;Bill Of Material&amp;#8221;的BOM表，而是Byte Order Mark。BOM是一个有点小聪明的想法：&lt;/p&gt;
&lt;p&gt;在UCS 编码中有一个叫做&amp;#8221;ZERO WIDTH NO-BREAK SPACE&amp;#8221;的字符，它的编码是FEFF。而FFFE在UCS中是不存在的字符，所以不应该出现在实际传输中。UCS规范建议我们在传输字节流前，先传输 字符&amp;#8221;ZERO WIDTH NO-BREAK SPACE&amp;#8221;。&lt;/p&gt;
&lt;p&gt;这样如果接收者收到FEFF，就表明这个字节流是Big-Endian的；如果收到FFFE，就表明这个字节流是Little-Endian的。因此字符&amp;#8221;ZERO WIDTH NO-BREAK SPACE&amp;#8221;又被称作BOM。&lt;/p&gt;
&lt;p&gt;UTF -8不需要BOM来表明字节顺序，但可以用BOM来表明编码方式。字符&amp;#8221;ZERO WIDTH NO-BREAK SPACE&amp;#8221;的UTF-8编码是EF BB BF（读者可以用我们前面介绍的编码方法验证一下）。所以如果接收者收到以EF BB BF开头的字节流，就知道这是UTF-8编码了。&lt;/p&gt;
&lt;p&gt;Windows就是使用BOM来标记文本文件的编码方式的。&lt;/p&gt;
&lt;p&gt;6、进一步的参考资料&lt;br /&gt;
本文主要参考的资料是 &amp;#8220;Short overview of ISO-IEC 10646 and Unicode&amp;#8221; (&lt;a href=&quot;http://www.nada.kth.se/i18n/ucs/unicode-iso10646-oview.html&quot;&gt;http://www.nada.kth.se/i18n/ucs/unicode-iso10646-oview.html&lt;/a&gt;)。&lt;/p&gt;
&lt;p&gt;我还找了两篇看上去不错的资料，不过因为我开始的疑问都找到了答案，所以就没有看：&lt;/p&gt;
&lt;p&gt;&amp;#8220;Understanding Unicode A general introduction to the Unicode Standard&amp;#8221; (&lt;a href=&quot;http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&amp;amp;item_id=IWS-Chapter04a&quot;&gt;http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&amp;amp;item_id=IWS-Chapter04a&lt;/a&gt;)&lt;br /&gt;
&amp;#8220;Character set encoding basics Understanding character set encodings and legacy encodings&amp;#8221; (&lt;a href=&quot;http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&amp;amp;item_id=IWS-Chapter03&quot;&gt;http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&amp;amp;item_id=IWS-Chapter03&lt;/a&gt;)&lt;br /&gt;
我写过UTF-8、UCS-2、GBK相互转换的软件包，包括使用Windows API和不使用Windows API的版本。以后有时间的话，我会整理一下放到我的个人主页上(&lt;a href=&quot;http://fmddlmyy.home4u.china.com/&quot;&gt;http://fmddlmyy.home4u.china.com&lt;/a&gt;)。&lt;/p&gt;
&lt;p&gt;我是想清楚所有问题后才开始写这篇文章的，原以为一会儿就能写好。没想到考虑措辞和查证细节花费了很长时间，竟然从下午1:30写到9:00。希望有读者能从中受益。&lt;/p&gt;
&lt;p&gt;附录1 再说说区位码、GB2312、内码和代码页&lt;br /&gt;
有的朋友对文章中这句话还有疑问：&lt;br /&gt;
&amp;#8220;GB2312的原文还是区位码，从区位码到内码，需要在高字节和低字节上分别加上A0。&amp;#8221;&lt;/p&gt;
&lt;p&gt;我再详细解释一下：&lt;/p&gt;
&lt;p&gt;&amp;#8220;GB2312 的原文&amp;#8221;是指国家1980年的一个标准《中华人民共和国国家标准 信息交换用汉字编码字符集 基本集 GB 2312-80》。这个标准用两个数来编码汉字和中文符号。第一个数称为&amp;#8221;区&amp;#8221;，第二个数称为&amp;#8221;位&amp;#8221;。所以也称为区位码。1-9区是中文符号，16-55 区是一级汉字，56-87区是二级汉字。现在Windows也还有区位输入法，例如输入1601得到&amp;#8221;啊&amp;#8221;。（这个区位输入法可以自动识别16进制的 GB2312和10进制的区位码，也就是说输入B0A1同样会得到&amp;#8221;啊&amp;#8221;。）&lt;/p&gt;
&lt;p&gt;内码是指操作系统内部的字符编码。早期操作系统的内码是与语言相关的。现在的Windows在系统内部支持Unicode，然后用代码页适应各种语言，&amp;#8221;内码&amp;#8221;的概念就比较模糊了。微软一般将缺省代码页指定的编码说成是内码。&lt;/p&gt;
&lt;p&gt;内码这个词汇，并没有什么官方的定义，代码页也只是微软这个公司的叫法。作为程序员，我们只要知道它们是什么东西，没有必要过多地考证这些名词。&lt;/p&gt;
&lt;p&gt;所谓代码页(code page)就是针对一种语言文字的字符编码。例如GBK的code page是CP936，BIG5的code page是CP950，GB2312的code page是CP20936。&lt;/p&gt;
&lt;p&gt;Windows中有缺省代码页的概念，即缺省用什么编码来解释字符。例如Windows的记事本打开了一个文本文件，里面的内容是字节流：BA、BA、D7、D6。Windows应该去怎么解释它呢？&lt;/p&gt;
&lt;p&gt;是 按照Unicode编码解释、还是按照GBK解释、还是按照BIG5解释，还是按照ISO8859-1去解释？如果按GBK去解释，就会得到&amp;#8221;汉字&amp;#8221;两个 字。按照其它编码解释，可能找不到对应的字符，也可能找到错误的字符。所谓&amp;#8221;错误&amp;#8221;是指与文本作者的本意不符，这时就产生了乱码。&lt;/p&gt;
&lt;p&gt;答案是Windows按照当前的缺省代码页去解释文本文件里的字节流。缺省代码页可以通过控制面板的区域选项设置。记事本的另存为中有一项ANSI，其实就是按照缺省代码页的编码方法保存。&lt;/p&gt;
&lt;p&gt;Windows的内码是Unicode，它在技术上可以同时支持多个代码页。只要文件能说明自己使用什么编码，用户又安装了对应的代码页，Windows就能正确显示，例如在HTML文件中就可以指定charset。&lt;/p&gt;
&lt;p&gt;有 的HTML文件作者，特别是英文作者，认为世界上所有人都使用英文，在文件中不指定charset。如果他使用了0&amp;#215;80-0xff之间的字符，中文 Windows又按照缺省的GBK去解释，就会出现乱码。这时只要在这个html文件中加上指定charset的语句，例如：&lt;br /&gt;
&amp;lt;meta http-equiv=&amp;#8221;Content-Type&amp;#8221; content=&amp;#8221;text/html; charset=ISO8859-1&amp;#8243;&amp;gt;&lt;br /&gt;
如果原作者使用的代码页和ISO8859-1兼容，就不会出现乱码了。&lt;/p&gt;
&lt;p&gt;再 说区位码，啊的区位码是1601，写成16进制是0&amp;#215;10,0&amp;#215;01。这和计算机广泛使用的ASCII编码冲突。为了兼容00-7f的ASCII编码，我 们在区位码的高、低字节上分别加上A0。这样&amp;#8221;啊&amp;#8221;的编码就成为B0A1。我们将加过两个A0的编码也称为GB2312编码，虽然GB2312的原文根本 没提到这一点。&lt;/p&gt;
&lt;p&gt;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8211;&lt;br /&gt;
一、几个基本概念&lt;br /&gt;
1、bit 与  byte&lt;br /&gt;
bite 是二进制的即0和1，译作比特。&lt;br /&gt;
Byte是指八个bit，代表一个Ansi或Ascii 代码，即一个英文字母，译作字节。由于汉字使用了16位（比特）代码，所以称为双字节。&lt;br /&gt;
其换算关系很简单，一byte等于八bit。&lt;br /&gt;
2，ANSI码，ANSI是（American National Standard Institude）的简写。ANCII是American Standard Code for Information Interchange的简写。&lt;br /&gt;
ANSI是以标准的八位来显示一个字符的，可以代表256字。基本上包括了拉丁语系中所需要的全部字符。起初美国人认为7位（比特）就足够了，因为2的 7次方等于128，而英文字母只有26个，大小写加一起52个，再加上十个数字，几个标点和数学运算符号，也够了。所以就制定了ANCII七位的代码系 统，这七位的代码系统的128位与ANSI的256中的前128完全一致，加之现在的计算机系统都能自动分别，所以，这两个概念也就不太分别了。&lt;br /&gt;
二、GB 2312 汉字编码字符集&lt;br /&gt;
GB2312 码是中华人民共和国国家标准汉字信息交换用编码，全称《信息交换用汉字编码字符集•基本集》，标准号为GB 2312―80（GB是&amp;#8221;国标&amp;#8221;二字的汉语拼音缩写），由国家标准总局发布，1981年5月1 日实施。习惯上称国标码、GB码，或区位码。它是一个简化字汉字的编码，通行于中国大陆地区。新加坡等地也使用这一编码。&lt;br /&gt;
GB 2312―80收录简化汉字及一般符号、序号、数字、拉丁字母、日文假名、希腊字母、俄文字母、汉语拼音符号、汉语注音字母，共7445个图形字符。其中 汉字以外的图形字符682个，汉字6763个。由于6763比那GB 2312-80要好记得多，尤其是在GBK也流行的时代，人们总是习惯用6763来代指那通行（同时也让我们痛苦了）若干年的字符系统。&lt;br /&gt;
GB 2312-80规定，&amp;#8221;对任意一个图形字符都采用两个字节（Byte）表示。每个字节均采用GB 1988-80及GB 2311-80中的七位编码表示。两个字节中前面的字节为第一字节，后面的字节为第二字节。&amp;#8221;习惯上称第一字节为&amp;#8221;高字节&amp;#8221;（Upper），第二字节为 &amp;#8220;低字节&amp;#8221;（low）。&lt;br /&gt;
GB 2312-80将代码分为94个区（Section），对应第一字节，每个区94个位（Position），对应第二字节。两个字节的值，分别为区号值和位号值各加32（20H）。我们通常所说的区位便由此而来。&lt;br /&gt;
GB 2312-80规定，01~09区（原规定为1~9区，为表示区位码方便起见，现改称01~09区）为符号、数字区，16~87区为汉字区。而10~15 区、88~94区是有待于&amp;#8221;进一步标准化&amp;#8221;的&amp;#8221;空白位置&amp;#8221;区域。便第10区推荐与第3区的94个图形字符（即GB1988-80中的94个图形字符）相 同，字形宽度为其宽度的一半。）&lt;br /&gt;
GB 2312-80把收录的汉字分成两级。第一级汉字是常用汉字，计3755个，置于16~55区，按汉语拼音字母/笔形顺序排列；第二级汉字是次常用汉字， 计3008个，置于56~87区，按部首/笔区顺序排列。字音以普通话审音委员会发表的《普通话导读词三次审音总表初稿》（1963年出版）为准，字形以 中华人民共和国文化部、中国文字改革委员会公布的《印刷通用汉字字形表》（1964年出版）为准。&lt;br /&gt;
例：汉字&amp;#8221;啊&amp;#8221;，第一字节为0110000，第二字节为0100001，即16区、01位，用16。&lt;br /&gt;
这 些字的来源我不知道是根据什么，但就我处理文献的情况看，有些是对很常用的字，如用于人名的&amp;#8221;�&amp;#8221;字，一是明代著名戏曲理论家&amp;#8221;沈�&amp;#8221;，一是南唐中主（同 时又是文学家）&amp;#8221;李�&amp;#8221;，出现频率比较高，但却没有收在6763之中，而象&amp;#8221;芏&amp;#8221;&quot;塄&amp;#8221;&quot;蓥&amp;#8221;等近千字几乎用不上的字却占据着极紧张的资源。&lt;br /&gt;
以后的GBK更有这种情况。&lt;br /&gt;
三、GB/T12345 汉字编码字符集&lt;br /&gt;
GB/T12345和GB2312一样，是中华人民共和国国家标准汉字信息交换用编码，全称《信息交换用汉字编码字符集辅助集》，标准号为GB/T12345-90，中华人民共和国国家技术监督局1990年6月13日发布，1990年12月1日实施。&lt;br /&gt;
GB/T12345-90是一个关于繁体汉字的编码标准。所谓&amp;#8221;辅助集&amp;#8221;，•是与&amp;#8221;基本集&amp;#8221;（GB2312-80）相对应而言。即：GB/T12345 是&amp;#8221;与GB2312相对应的图形字符集。原则上，本字符集是将GB2312中的简化字用相应的繁体字替换而成。因此，这些替代的繁体字具有与被替代的简化 字相同的编码；未曾简化的汉字以及非汉字图形字符，仍是GB2312中的汉字及图形字符，并具有与之相同编码。&amp;#8221;&lt;br /&gt;
关于繁体字替换简化字的原 则，GB/T12345注明：&amp;#8221;本标准原则是按照《简化字总表》中所列繁体字与简化字的对应关系进行替换。&amp;#8221;《简化字总表》由中国文字改革委员会1964 年5月发表，后经国家语言文字工作委员会作个别修订，国务院1986年6月4日批准重新发表。&lt;br /&gt;
除了以上的根本差异外，GB/T12345与GB2312的区别还有以下几点：1，增补了个别图形字符，共收录7583个图形字符：汉字以外的图形字符716个，汉字6866个（其中一级汉字3755个，二级汉字3008个，增补汉字103个。）&lt;br /&gt;
a，&amp;#8221;根据排版需要，增补了竖排标点符号29个，这些字符增补于6区57位至85位。&amp;#8221;&lt;br /&gt;
b，&amp;#8221;根据GB5007.1（《信息交换用汉字24×24点阵字模集》），增加了6个汉语拼音用图形字符，这些字符增补于8区27位至32位。&amp;#8221;&lt;br /&gt;
c，&amp;#8221;GB2312中，由于60年代汉字简化被精简的字有103个，这些被精简的字根据繁体字处理系统的需要增补于88~89区。&amp;#8221;所谓精简，即废除某 个繁体字，而用另一个字代替，如废除&amp;#8221;�&amp;#8221;字，而以&amp;#8221;云&amp;#8221;字代替。由此形成一个简化字对应两个或两个以上繁体字的现象。&lt;br /&gt;
2，GB/T12345规定的在七位环境中指明图形字符集的转义序列不同，同时规定了在八位环境中的转义序列。&lt;br /&gt;
GB/T12345没有指明其字符集字形依据，便它使用的繁体汉字，与《简化字总表》中所使用的字形一致。其绝大多数汉字，使用了&amp;#8221;新字形&amp;#8221;。例如， &amp;#8220;产&amp;#8221;的繁体字，它使用了新字形&amp;#8221;�&amp;#8221;，而不自旧字形&amp;#8221;�&amp;#8221;。因此，一些旧字形与新字形的差异，被视为字形的差异（异体字），而不是繁体与简体的差异。 如：收录&amp;#8221;奂&amp;#8221;&quot;换&amp;#8221;&quot;唤&amp;#8221;，而不用&amp;#8221;�&amp;#8221;&quot;�&amp;#8221;&quot;�&amp;#8221;，即因为&amp;#8221;�&amp;#8221;是旧字形，而非繁体字。但是其中极个别字又使用了旧字形，如&amp;#8221;为&amp;#8221;&quot;伪&amp;#8221;的繁体字， 使用了旧字形&amp;#8221;�&amp;#8221;&quot;�&amp;#8221;，而上用新字形&amp;#8221;�&amp;#8221;&quot;�&amp;#8221;。关于新旧字形，可参见中国社会科学院语言研究所编纂的《现代汉语词典》（商务印书馆1978年第一 版）、《新华字典》（商务印书馆1979年修订版）所附的《新旧字形对照表》，以及辞海编辑委员会编纂的《辞海》（上海辞书出版社1979年出版）所附的 《新旧字形对照举例》。&lt;br /&gt;
关于被精简的汉字：&lt;br /&gt;
1，88~89区所列的103个汉字，GB/T12345称为&amp;#8221;60年代汉字简化时被精简 的字。&amp;#8221;，这一表达不完全准确。例如：，&amp;#8221;丰&amp;#8221;与&amp;#8221;�&amp;#8221;，汉字简化时精简了&amp;#8221;�&amp;#8221;字，以&amp;#8221;丰&amp;#8221;字替代，而GB/T12345将被精简的&amp;#8221;�&amp;#8221;字，作为 &amp;#8220;丰&amp;#8221;的繁体，置于23~65，而将&amp;#8221;丰&amp;#8221;字置于88~19。类似的情况占其103字的三分之一左右。&lt;br /&gt;
2，所谓103个&amp;#8221;被精简的汉字&amp;#8221;，只 是被精简的&amp;#8221;繁体字&amp;#8221;，而未包括被精简（废除）的&amp;#8221;异体字&amp;#8221;。例如，&amp;#8221;�&amp;#8221;和&amp;#8221;�&amp;#8221;，作为&amp;#8221;升&amp;#8221;的异体字，被停止使用，GB/T12345亦未收录。相关 的法定文件为中华人民共和国文化部、中国文字改革委员会1955年6月发布的《第一批异体字整理表》，该表列出异体字810组，1865字，并规定废除异 体字1055个。一些异体字，习惯上也被看作是简化字，所以，《简化字总表》特地从《第一批异体字整理表》中选出39个异体字，列为附录。&lt;br /&gt;
3，按照汉字简化原则，在容易引起歧义时不简化。例如&amp;#8221;余&amp;#8221;和&amp;#8221;�&amp;#8221;，《简化字总表》对&amp;#8221;�&amp;#8221;字的脚注说；&amp;#8221;在余和�意义可能混淆时，仍用�，如文言句 &amp;#8220;�年无多&amp;#8221;。同时，有些汉字只简化其字义的某一个或几个义项，如徵，在象徵等义项上被简化为征，而在音乐调值的义项上（即宫商角徵羽的徵，读作zhi [止]），并不简化。因此在GB2312中，保留了个别繁体（或异体）字，也就是说，同时收录了一个字的简体和繁体（或异体），这包括&amp;#8221;干乾、后後、伙 夥、么麽、于於、余�、折摺、征徵&amp;#8221;等。作为与GB2312对应的繁体编码，GB/T12345在这些字上处理较混乱。例如：GB/T12345将&amp;#8221;伙&amp;#8221; 置于27-79，&amp;#8221;夥&amp;#8221;置于66-23，与GB2312��相同，即，以&amp;#8221;伙&amp;#8221;��&amp;#8221;伙&amp;#8221;，以&amp;#8221;夥&amp;#8221;��&amp;#8221;夥&amp;#8221;。另一�情�是，GB/T12345� &amp;#8220;後&amp;#8221;置于26-83，对应GB2312的&amp;#8221;后&amp;#8221;，将&amp;#8221;後&amp;#8221;置于65-65，对应GB2312的&amp;#8221;後&amp;#8221;；将&amp;#8221;徵&amp;#8221;置于53-87，对应GB2312的 &amp;#8220;征&amp;#8221;，将&amp;#8221;征&amp;#8221;置于65-71，对应GB2312的&amp;#8221;徵&amp;#8221;，显然不当。&lt;br /&gt;
注：&lt;br /&gt;
1，以上代码表，除06、08区增补符号用GIF图形编制外，其他均使用GBK代码编制，只有在你的电脑能完全正确GBK汉字时，才能保证看到的上表与GB/T12345标准印刷件（中国标准出版社1991年10月版）相同的字形。&lt;br /&gt;
2，尽管满足查看GBK汉字的条件，仍有两个汉字的显示，与GB/T12345标准印刷件有所差异。两个字的代码为47-22、80-89。第一字的印 刷件字形，未列入有关简化字的法定文件，但习惯上被视为&amp;#8221;隙&amp;#8221;的繁体，而GBK编码未收录此字，无法显示，故以&amp;#8221;隙&amp;#8221;替代。第二字的印刷件字形，系对应简 体&amp;#8221;�&amp;#8221;，按照《简化字总表》第二表《可作简化偏旁的简化字和简化偏旁》，&amp;#8221;�&amp;#8221;简化为&amp;#8221;夹&amp;#8221;，所以，&amp;#8221;瘗&amp;#8221;对应的繁体字，应该是&amp;#8221;瘗&amp;#8221;，同时，印刷件上 的此字不见于字书，因此它可能是排版时错误，故上表使用了&amp;#8221;瘗&amp;#8221;字。&lt;br /&gt;
3，01~15区的符号和空白位置，除增补者以外，与GB2312的符号、编码位置完全相同。&lt;br /&gt;
&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8211;&lt;br /&gt;
四、BIG-5字符集&lt;br /&gt;
BIG-5码是通行于台湾、香港地区的一个繁体字编码方案，俗称&amp;#8221;大五码&amp;#8221;。它并不是一个法定的编码方案，存在着一些瑕疵，业界的评价也不高，但它广泛地被应用于电脑业，尤其是在国际互联网中，从而成为一种事实上的行业标准。&lt;br /&gt;
关于BIG-5码的背景，一直未见详细记载，简单介绍如下：&lt;br /&gt;
1983年10月，台湾国家科学委员会、教育部汉字推行委员会、中央标准局、行政院主计处电子资料处理中心共同制定了《通用汉字标准交换码》 （chinese  Ideographic  standard  code for  information  interchange ，简称CISCII码），经试用修订，1986年8月4日由台湾中央标准局公布为法定标准，标准编号为CNS 11643。这一标准于1992年5月21日重新修订公布，更名为《中文标准交换码》（chinese standard  interchange  code）.1995mm 1 月4日，台湾中央标准局又公布了CNS 11643-1《中文标准交换码使用方法》。&lt;br /&gt;
BIG-５码是1984年台湾信息工业促进会根据《通用汉字标准交换码》制订的编码方案。至于为何称为&amp;#8221;BIG-5&amp;#8243;。&lt;br /&gt;
BIG-5码是一个双字节编码方案，其第一字节的值在16进制的AO~FE之间，第二字节在40~7E和A1~FE之间。因此，其第一字节的最高位是1，第二字节的最高位则可能是1，也可能是0。&lt;br /&gt;
BIG-5码的图形符号及汉字，基本与CNS 11643标准的第一、第二字面（Plane）一致，它收录13461个符号和汉字，包括：&lt;br /&gt;
1，符号408个，编码位置为A140~A3FE（实际止于A3BF，末尾有空白位置。）&lt;br /&gt;
2，汉字13053个，分为常用字和次常用字两部分，各部分中的汉字按笔划/部首排列。其中：&lt;br /&gt;
a，常用字5401个，编码位置为A440~C67E。包括台湾教育部颁布的《常用汉字标准字体表》中的全部汉字4808个，台湾国中国小教科书常用字587个，异体字6个。&lt;br /&gt;
B，次常用字7652个，编码位置为C940~F9FE（实际止于F9D5，末尾有空白位置）。包括台湾教育部《次常用汉字标准字体表》的全部汉字6341个，《罕用汉字标准字体表》中使用频率较高的字1311个。&lt;br /&gt;
其余的A040~A0FE、C6A1`FEFE为空白区域。一些空白位置，经常被用于用户造字区，而且多存放香港常用字和粤语方言字。&lt;br /&gt;
现在流行的BIG-5码字库，在F9D6~F9DC位置大都有7个常用字，据说为倚天系统所增。若计此7字，则全数为13060个汉字，13468个汉 字和符号。此外，一些BIG-5码字库，如Windows繁体中文版的True Type细明体（华康科技提供，2.0版），在F9DD~F9FE位置还有33个制表符和1个&amp;#8221;■&amp;#8221;符号。&lt;br /&gt;
五，BIG5+码&lt;br /&gt;
1，编订BIG5+码之缘起&lt;br /&gt;
台湾行政院协助解决众多使用BIG5码政府单位于进行公文电子传递时寓到自造字无法转换CNS问题，而于数次会商后决议成立专案委托中文电脑基金会办理[BIG5码字集扩编计划]，86年7月扩编完成。&lt;br /&gt;
2，编码原则&lt;br /&gt;
BIG5 +码系以CNS为蓝本，共增编标准字集4760个字符与推荐字集3250个字符；其标准字集即纳编CNS第3字面字集内之4145个，第4个字面字集内之 219个字，均为一般文书常用之中文字，如推广应用于研究发新版中文软体，则估计可解决80％的BIG5自造字转换CNS交换码问题。&lt;br /&gt;
（一），长度仍为双字节，即高字节之第一位元（MSB）=1。&lt;br /&gt;
（二），保留原有之标准字集字区及使用者加字区，使与原有系统具相容性。&lt;br /&gt;
（三），以国家标准（CNS11643）及国际标准（ISO10646）字集为字源范围，并依CNS之序编入。&lt;br /&gt;
（四）包含于ISO10646或CNS11643字集内且市面已广为使用之倚天自造字及符号，编入标准字集并保留原码位。&lt;br /&gt;
（五），单独成字之部首不再重覆编码（如金、木、水、火、土）。&lt;br /&gt;
（六），有重复的字删除其后者，错字则依CNS修正之。&lt;br /&gt;
3，字码架构&lt;br /&gt;
（一），总码位：由原有之19782个扩大为23940个（高字节为81-FE，低位元组为40-7E、80-FE）。&lt;br /&gt;
（二）编码区间&lt;br /&gt;
a，第一标准字集：此区即原BIG-5码标准字集但删除22个重字，编码范围为A140-F9FE（高字节为A1-F9，低字节为40-7E、A1- FE）。共有13973个字符，包括常用汉字5401个（A440-C67E），次常用汉字7693个（C940-F9D5）及符号471个（A140- A3FE）、字符408个（C6A1-C8FE）。&lt;br /&gt;
b，第二标准字集：此区即扩编部分，编码范围为8180-FEA0（高字节为81-F9，低字节为80-A0）。共收编罕用汉字4158个。&lt;br /&gt;
c，CMEX推荐字集：因BIG-5码系统之编码位置有限，未能编入第一及第二标准字集之较常用罕用及异体汉字、简体字与日韩汉字3454个，经中推会 （CMEX）建议集中收编于此区。编码范围为原造字区之8140-83FE、8E40-A0FE（高字节为81-83、8E-A0，低字节为40―7E、 A1-FE）。&lt;br /&gt;
d，造字区：仅使用第二标准字集时，仍保留5809个码位供使用者造字，可编码区间不变；但同时使用推荐字集时，因BIG5+ 码之推荐字集系使用原造字区之8140-83FE及8E40-A0FE，供造字之码位仅余2355个，可编码区间为FA40-FEFE（785个码位）、 8440-8DFE（1570个码位）。&lt;br /&gt;
e，使用者专用字集：为使各行业专用之字集亦能进行信息交换，向中推会申请登记ID后，将ID字形等依照 输规定传出供对方显示或列印。&lt;br /&gt;
使用者专用字集之编码区与CMEX推荐字集相同，亦使用到原造字区。&lt;br /&gt;
4，可用之工具&lt;br /&gt;
（一），24＊24点阵字形档。&lt;br /&gt;
（二），注音符号、仓颉码属性档。&lt;br /&gt;
（三），CNS11643、ISO10646码对照档。&lt;br /&gt;
（四），BIG5+〈――〉ISO10646转码程序。&lt;br /&gt;
（五），BIG5+〈――〉CNS11643转码程序。&lt;br /&gt;
（六）BIG-5码自造字转BIG-5码管理程序。&lt;br /&gt;
（七）BIG-5自造字转码程序。&lt;br /&gt;
5，使用方法&lt;br /&gt;
因BIG5+码在标准字集外尚提供推荐字集，各单位可依自己原有造字情况选择适当之使用方法：&lt;br /&gt;
（一）字集之使用1.以下情可使用全字集（即第一、第二标准字集及推荐字集，共21585个字符）&lt;br /&gt;
（1），全无自造字者。&lt;br /&gt;
（2），原来已有自造字，其编码区间未与推荐字集重叠者，（即FA40―FEFE及8440-8DFE以外）&lt;br /&gt;
（3），原来已有自造初开球编码区间虽与推荐字集重叠，但可全部转换为新码者。&lt;br /&gt;
（4），原来已有自造字，但经转换为新码后剩余自造字未超过2355个，且可以或原意改置于FA40-FEFE及8440-8DFE以外者。2.以下情况仅使用标准字集（即第一与二标准字集，共13461个字符）：&lt;br /&gt;
（1），有自造字，但转码后剩余自造字仍超过2355个者。&lt;br /&gt;
（2），原有自造字耸部或部分落于FA40-8440-8DFE两个造字区（推荐字集使用范围）内，不易或不愿转换为新码者。&lt;br /&gt;
（二）字形转输与交换规格之使用&lt;br /&gt;
BIG -5码虽已扩编，但其余未能纳入自造字及未来不断新增之自造字，依旧会产生交换及传送问题；为使这些自造字于网路传输及档案交换时，仍可作字形显示与列 印，特订定以下几项规格：1，文件档案交换传输规格，依SGML（ISO8879）格式及CNS（ISO9541）字形资讯交换规格，订定SGML文件档 案内字形应含之参数。2，中文周边装置字形下载规格：包括中文终端机、打印机及其他终端设备，系依CNS13479（ISO6429）规范订定字形下载之 规格。&lt;br /&gt;
（三）用户需准备之工作&lt;br /&gt;
BIG-5码编扩编后纳入之自造字，如不作转码，将来交换时一定会发生一字两码的问题，因此在BIG5+码 之新版中文系统软体推出前，用户必需先转换现在自造字之旧码，其程序如下：1，建立自造字之旧码与扩编后新码对照表：各单位之造字区管理者可利用第六项工 具[BIG5自造字转标准字对照表管理程式]比对造字区内自造字后建立单位内新/旧码对照表。2，清查需要转码之资料档：各单位或集中或各自处理，均必需 先清查所有用过原造字区字码之料档，以备进行转码。3，自造字旧码之转换：各项业务负责人或各使用者可利用第七项工具[BIG5自造字转标准字转换程式] 及所建立之单位内新/旧码对照表，将所有的[文字档（.txt。）原用之自编旧码转换为BIG5+新码。4，单位内造字区之重整；为避免转码后发生一字两 码之现象，各单位原有之造字区应作整理，删除已编入BIG5+码系统者，其余自造字则保留原编码或重新编码（重整造字区）。&lt;br /&gt;
6，应用现况&lt;br /&gt;
台湾厂商如：芙蓉坊、昌泰科枝、大同、倚天等公司已将BIG5+码应用于新产品中。&lt;/p&gt;
&lt;p&gt;六、台湾制定的CNS11643&lt;br /&gt;
1，编订中文标准交换码之缘起&lt;br /&gt;
72年10月由台湾科学委员会、教育部、中央标准局及本中心合编[通用汉字标准交换码]后决议试用二年；试用期满，经检讨修正重编并向中央标准局申请订 为国家标准，75年8月4日获该局审定公布国家标准，编号[CNS11643]；81年51 21日再由该局因应实际需要修订扩编，并更名为[中文标准交换码（chinese standard interchange code）]。&lt;br /&gt;
2，CNS11643之适用范围&lt;br /&gt;
本标准适用于中文信息之处理。&lt;br /&gt;
3，编码之各项考虑&lt;br /&gt;
中文信息标准交换码是否能普遍地推广使用，使一般使用者共同乐意接受，端视其是否具有实用性，因此本码之编码原则研订时，曾先就标准码的结构、编码需求等作多方面的周密考虑。&lt;br /&gt;
（一），以教育部所公布的四个字体表之字集为范围。&lt;br /&gt;
（二），根据使用的频率及范围，整理后分别编排于各个字面，以适应各个层次之使用者。&lt;br /&gt;
（三），符合国际信息传输上所使用之CNS5205[信息处理及交换用七位码字符集]及CNS7654[信息处理-七位及八位码字符集-延码技术]标准通信定则。&lt;br /&gt;
（四）涵盖常用之外语字母及工商界与学校所使用之文字及符号。&lt;br /&gt;
4，字集编排原则&lt;br /&gt;
（一），中文标准交换码分为十六个字面，每个字面可陈列94列＊94行，即8836个字符。目前第一至第七字面列有字集，第八至第十一字面预留扩编之用；第十二至第十六字面则为使用者加字区，凡未收于本码系统之中文及符号，他用者可视需要自行编订于加字区使用。&lt;br /&gt;
总支持文字量达141376个。&lt;br /&gt;
（二）各字面字集排列大抵依使用频率为次序，每一字面以常用字为主，第二字面以次常用字为主，第三字面以部分罕用字及较常用异体字为主，第四字面以 ISODIS10646第二版之汉字、各单位/信息业用字及户政用字为主，第五字面以罕用字为主，第六、第七字面以异体字为主。其中第一第二字面字集先于 民国七十五年八月四日公布为国家标准。&lt;br /&gt;
5，字码编排原则&lt;br /&gt;
（一），文字之选择及字体悉依教育部[汉字标准字体表]为基准。说明：中 国文字的困扰主要有两方面，一是文字的数量太大，二是异体字繁多。实际上一般人常用的不过七千字左右，新字又不断的增加，造成中文资料处理上的困难；而教 育部的标准字体表之字集系经多年之搜集、考证、分析、选取，为较不偏颇，最具客观性之用字字集，应能符合一般使用者之需求。&lt;br /&gt;
（二），以2个字节（bytes）为中文码编码单位，并以十六进位制之文数字表示之。说明：[以2个字节为字码单位，于处理时可增加信息传输之速度]，符合一般资料处理作业之需要。采用十六进位制数字编码，系因应资料处理人员惯用之进位法，用以表示两字节最为简明。&lt;br /&gt;
（三）符合CNS5205及CNS7654之通信定则。说明：本编码为符合CNS5305及CNS7654通信定则之规定，所有控制码均予避开，即字码 中之00至20以及7F均予避开，则7BIT字码集共有94个编码位置，两个字节革命可编8836个中文字码，订为一字面。&lt;br /&gt;
（四），依字之使用频率而编排于各不同字面。说明：在做信息传输时，若欲传送出现在不同字面上的字，必须先送出转字面控制码。为提高传输效率，常会一起出现的字编在同一字面中，可减低字面转换的次数。&lt;br /&gt;
（五），使先笔画后部首的排列顺序来编订字码。说明：每一字面均按文字灭口笔画数为首序编订字码，使用者以笔画数即可查寻字码。&lt;br /&gt;
六、字集之说明&lt;br /&gt;
第一字面：本编码系统为减少字面转换次数，特编最常用之中文字及符号、字母、部首等于第一字面；所编字汇及码区分别说明如下：&lt;br /&gt;
1，符号区&lt;br /&gt;
符号区之编码位置规划于第一字面之2121至427E，有3102个编码位置，目前暂编符号684个，所余空位供尔后增添之用。&lt;br /&gt;
已编入之特殊符号及文字类别如下：&lt;br /&gt;
（1），间隔符号1个。&lt;br /&gt;
（2），标点符号28个。&lt;br /&gt;
（3）括号及制表符号89个。&lt;br /&gt;
（4），一般符号34个。&lt;br /&gt;
（5）、学术符号51个。&lt;br /&gt;
（6）、单位符号31个。&lt;br /&gt;
（7）数字符号42个，包括阿拉伯数字10个，罗马数字大小写共20个，中国数字12个。&lt;br /&gt;
（8）外文字母100个，包括大写英文字母，小字英文字母各26个，大写希腊字母、小写希腊字母各24个。&lt;br /&gt;
（9）汉字注音符号42个。&lt;/p&gt;
&lt;p&gt;（10）数字序列符号20个。&lt;br /&gt;
（11）中国文字部首213个（夕，夕两部首同归于夕部首中，夕部首得于将来扩编时一并列入增订。）&lt;br /&gt;
（12）控制码符号33个。&lt;br /&gt;
2 中文字区&lt;br /&gt;
CNS第一字面之中文字区编码区间由4421至7D4B，所编字汇5401字，除包括教育部颁订之&amp;#8221;常用汉字标准字体表&amp;#8221;所列全部4808字外，并优收 编国中、国小教科书中常用字587字及异体字6字。第二字面：本字集所编字汇7650字，除教育部所颁&amp;#8221;次常用汉字标准字体表&amp;#8221;外，并筛选编入罕用字表中 使用频率较高之1320字。字码区间为2121至7244。第三字面：本字集即77年6月行政院主计处电子处理资料中心为搜集仍涵盖教育部罕用及异体字表 中之较常用字，所编订之使用者加字区第14字面字集第一部分，字数6148字；原码序不变，字码区间仍为2121至6246。第四字面：本字集所编字汇 7298字，除包括原第14字面第二部分171字外，并搜集户役政及其他使用单位，ISO10646第2版汉字集、信息业次常用字而成，字码区间为 2121至6E5C。第五字面：本字集所编字汇共8603个字，系未包含于前4个字面之教育部罕用字。字码区间为2121至7C51。第六字面：本字集所 编字汇共6388个字，为不包含于前5个字面且笔画在14画（含）以下之教育部异体字。字码区间为2121至647A。第七字面：本字集所编字汇6539 个字，为不包含前6个字面之教育部异体字，字码区间为2121为6655。使用者得视自己的需求参考本标准之字集、字序编订内码表。&lt;br /&gt;
七，CNS11643之使用&lt;br /&gt;
（一）字面之指定与转换依据CNS7654（78年7月15日版）第5。3。9节之规定，中文码可置于多字节符号字库（MULTIPLE BYTE GRAPHIC  REPERTOIRE）中，经由ESC2/4 2/9 F四个字节之逸出顺序码指定于G1字集，或经由ESC2/4 2/10 F 指定于G2字集，亦可经由ESC2/4 2/11 F指定于G3字集，其中F 可用3/0~3/15来指定相对之一至十六中文字面；至于英文之字集则可经由ESC2/8 F 指定于G0字面。在7个位元的环境下，对于各种字面的使用说明如下：1，利用SI使用G0字面，并为锁定方式。        2，利用SO使用G1字面，并为锁定方式。3，利用LS2使用G2字面，并为锁定方式。4，利用LS3使用G3字面，并为锁定方式。5，利用SS2使用 G2字面，并为非锁定方式。6，利用        SS3使用G3字面，并为非锁定方式。&lt;br /&gt;
为求使用方便，终端设备在开机时可将G0、G1、G2等三个字集分别设定为ASCII、第一字面及第二字面，将G3字集设定为其他较常用的字面。有关这些控制码的使用，请参考CNS7654        。&lt;br /&gt;
（二）使用者加字区之使用：&lt;br /&gt;
为适应各种不同性质之中文资料处理作业，CNS11643特别订定自第十二字面起为使用者加字区；尚未收编于本系统之中文字或符号。由使用者视需要先编于此区内使用；字面之指定与转换方法与前七个字面相同。&lt;br /&gt;
八，CNS11643之推广应用&lt;br /&gt;
本交换码系统依国家标准法之规定，系由经济部中央标准局负责检讨增修之，但该局为加强推广该标准之应用，特将此系统及中文字型档委托本中心代为办理推广 应用事宜；本中心为顾及标准字型档之完整性，以利此标准之推广，另再商得内政部及经济部工业局同意一并提供其他字型档。&lt;br /&gt;
CNS11643目前之应用情形如下：&lt;br /&gt;
（一）台湾之应用情形&lt;br /&gt;
1，公文电子交换之标准传递码，行政院&amp;#8221;政府机关公文电子传递作业&amp;#8221;决定，凡是经&amp;#8221;交换中心&amp;#8221;（交通部管资中心）之公文，一律须先转换为CNS后再传递。&lt;br /&gt;
2，EUC码援用CNS之字集及架构：UNIX系统上使用之EUC虽为4BYTE之内码，但却全部采用CNS之编码架构及字集；其2个低字节之HIGH均OFF后字码即与CNS完全相同，因此不需再以对照表方式转换；亦可视为CNS应用于内码之实例。&lt;br /&gt;
3，BIG5+码之字源：86年7月完成之&amp;#8221;BIG5+&amp;#8221;（即BIG-5码之扩编）系以CNS11643为蓝本，纳编CNS第3字面之4，145个、第4字面之219个一般文书常用之中文字。&lt;br /&gt;
（二）国外之应用情形&lt;br /&gt;
ISO10646及UNICODE汉字均收编CNS字集：ISO10646及UNICODE目前共收编20902个汉字，其中17011个字系来自 CNS（第1第2字面及第3字面3895个，第4字面56个），现又增编CNS的5881个字。因此，不便台湾标准得与国际标准相容，国内电脑业者在国际 市场之竞争力得以增强，将来ISO10646及UNICODE发展成熟后，使用者亦可得以顺利转换。&lt;br /&gt;
七，CCCII编码&lt;br /&gt;
CCCII编码是CHINESE CHARACTER CODE FOR INformATION INTERCHANGE 的缩写，是经台湾中研院中美会及国科会等单位支持，于1979年12月25日集合由台湾图书馆学者，文字学家及电脑专家组成&amp;#8221;汉字整理小组&amp;#8221;提出的汉字编 码，已广泛用于港台图书馆及与美国网上数字化图书信息中心OCLC系统。该编写系统提供了94面（PLANE）×行（ROW）×94列（CELL）= 830584字符空间；其中每六个面构成一个层（LAYER）提供6×94×94=53016编码空间，（最后一层只有四个面）。各层定义的汉字情况如 下：&lt;br /&gt;
第1层，符号和繁体汉字。&lt;br /&gt;
第2层，大陆的简体汉字。&lt;br /&gt;
第3-12层，汉字异体字。&lt;br /&gt;
第13层，日本汉字。&lt;br /&gt;
第14层，朝鲜汉字。&lt;br /&gt;
第15层，保留字。&lt;br /&gt;
第16层，杂项字（日本与朝鲜）&lt;br /&gt;
第一至十二层的编码的编码存在关联含义，就是说同样的码在这些不同的层表示同一个汉字的不同变形。如第一层表示繁体字，第二层表示大陆简体字（如果有的话），第三至十二层表示其他的异体字，例如以下这个字的三种变形，编码的第二三字节是相同的：&lt;br /&gt;
字形类型编码点，层字样&lt;br /&gt;
繁体字  OX224E411&lt;br /&gt;
简体字  OX284E412&lt;br /&gt;
异体字  OX2E4E413&lt;br /&gt;
第一层所定义的字符集如下：第1面/第2行56数学符号第1面/第3行ASCII第1面/第11行35中文标点符号第1面/第12-14行214康熙字 典偏旁部首第1面/第15行41中文数字，37拼音符号，4音调符号第1面/第16-67行4808备用字，字码213021-21637E第1面/第 68行-第3面/第64行17032备用字，字码216421-23607E20583罕用字，字码为236121-262543第3面/第65行含教育 部颁定之罕用字汇12924字，次常用字汇314字，第6面/第5行以及康�字典、中文大辞典、财税资料考核中心字汇、电信传输码字汇、五大专题码字汇， 与其他信息字汇7345字。&lt;br /&gt;
第二层收异体字共11517字，其中包含大陆简体字3625字，其它简体字7892字所有各层的第一行均为保留行，共收字53940个。&lt;br /&gt;
四交大资料-BBS95年1月中国文字资料库（CCDB）字型集的应用（1）中国文字资料库（CCDB）字型集的应用（2）中国文字资料库（CCDB） 字型集的应用（3）中国文字资料库（CCDB）属性档介绍。三，ANSIZ39.64-1989 THIS NATIONAL STANDARD IS DESIGNATED as ANSIZ39.64-1989 and named &amp;#8220;EAST ASIAN CHARACTER CODE&amp;#8221;（EACC），but was origianlly known as REACC (RLIN EAST ASIAN CHARACTER CODE), THAT IS BEFORE IT BECAME A NATIONAL STANDARD RLIN STANDS FOR &amp;#8220;RESEARCH LIBRARIES INformATION NETWORK &amp;#8221; which was developed by the&lt;br /&gt;
B ，浏览器：IE4。01（或更高的版本）中文版，或NETSGAPE NAVIGATOR 3。X&lt;br /&gt;
2，其他语种的WINDOWSS 95（或更高的版本）+微软简体中文支持或外挂中文平台。一般情况下，使用外挂中文平台时，需要将当前环境设置成为GBK码，并关闭汉字自动识别的功能。而且，许多外挂中文平台不支持全部GBK汉字。&lt;br /&gt;
3，已知的常见错误。&lt;br /&gt;
A，IE4。0无法显示GBK/4 AB-AF、F9-FD以及FE 中 FE40-FE4F各位置的汉字。&lt;br /&gt;
B，在简体WINDOWS95环境下，NETSGAPE NAVIGATOR4。X 无法显示GBK/3中XXA0位置的汉字，A040-AOFE位置显示错误。&lt;br /&gt;
C，在繁体WINDOWS95环境下，NETSGAPE NAVIGATOR4。X不能正确显示GBK/3-GBK/5之间的字符。&lt;br /&gt;
GBK代表码（按分类顺序排列）&lt;br /&gt;
GBK/1：GB2312非汉字符号A1-A9&lt;br /&gt;
B0-B7B8-BF C0-C7C8-CF D0-D7&lt;br /&gt;
GBK/2：GB2312汉字&lt;br /&gt;
D8-DFE0-E7E8-EFF0-F7&lt;br /&gt;
81-8384-87 88-8B8C-8F 90-93&lt;br /&gt;
GBK/3：扩充汉字&lt;br /&gt;
94-9798-9B 9C-A0&lt;br /&gt;
AA-AFB0-B7B8-BFC0-C7C8-CF&lt;br /&gt;
GBK/4：扩充汉字&lt;br /&gt;
D0-D7D8-DFE0-E7E8-EFF0-F7&lt;br /&gt;
F8-FE&lt;br /&gt;
GBK/5：扩充非汉字&lt;br /&gt;
A8-A9&lt;br /&gt;
（1）AA-AF  （2）F8-FE&lt;br /&gt;
用户自定义区&lt;br /&gt;
（3）A1-A7&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/596885652/yahooblog/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/yahooblog/~7260371/596885652/5002429/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://blog.so8848.com/2011/09/3962.html/feed</wfw:commentRss><slash:comments>0</slash:comments><description>汉字编码问题 下面是搜集的多篇关于汉字编码问题文章的合集，相信你的问题一定包含在其中，如果没有请留言，一起把这方面的内容补充全。一、汉字编码的种类 汉字编码中现在主要用到的有三类，包括GBK，GB2312和Big5。 1、 GB2312又称国标码，由国家标准总局发布，1981年5月1日实施，通行于大陆。新加坡等地也使用此编码。它是一个简化字的编码规范，当然也包括其他 的符号、字母、日文假名等，共7445个图形字符，其中汉字占6763个。我们平时说6768个汉字，实际上里边有5个编码为空白，所以总共有6763个 汉字。 GB2312规定&amp;#8221;对任意一个图形字符都采用两个字节表示，每个字节均采用七位编码表示&amp;#8221;，习惯上称第一个字节为&amp;#8221;高字节&amp;#8221;，第二个字节 为&amp;#8221;低字节&amp;#8221;。GB2312中汉字的编码范围为，第一字节0xB0-0xF7(对应十进制为176-247)，第二个字节0xA0-0xFE（对应十进制 为160-254）。 GB2312将代码表分为94个区，对应第一字节（0xa1-0xfe）；每个区94个位（0xa1-0xfe），对应第二 字节，两个字节的值分别为区号值和位号值加32（2OH），因此也称为区位码。01-09区为符号、数字区，16-87区为汉字区（0xb0- 0xf7），10-15区、88-94区是有待进一步标准化的空白区。 2、Big5又称大五码，主要为香港与台湾使用，即是一个繁体字编码。每个 汉字由两个字节构成，第一个字节的范围从0X81－0XFE（即129-255），共126种。第二个字节的范围不连续，分别为0X40－0X7E（即 64-126），0XA1－0XFE（即161-254），共157种。 3、GBK是GB2312的扩展，是向上兼容的，因此 GB2312 中的汉字的编码与GBK中汉字的相同。另外，GBK中还包含繁体字的编码，它与Big5编码之间的关系我还没有弄明白，好像是不一致的。GBK中每个汉字 仍然包含两个字节，第一个字节的范围是0&amp;#215;81-0xFE（即129-254），第二个字节的范围是0&amp;#215;40-0xFE（即64-254）。GBK中有码 位23940个，包含汉字21003个。 表1 汉字编码范围 名称    &amp;#124;       第一字节          &amp;#124;           第二字节 &amp;#8212;&amp;#8212;&amp;#8211;&amp;#124;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;-&amp;#124;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212; GB2312  &amp;#124;   0xB0-0xF7(176-247)    &amp;#124;    0xA0-0xFE（160-254） &amp;#8212;&amp;#8212;&amp;#8211;&amp;#124;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;-&amp;#124;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;- GBK0    &amp;#124;  x81-0xFE（129-254）    &amp;#124;   0&amp;#215;40-0xFE（64-254） &amp;#8212;&amp;#8212;&amp;#8211;&amp;#124;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;-&amp;#124;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;- Big5    &amp;#124;   0&amp;#215;81-0xFE（129-255）  &amp;#124;   0&amp;#215;40-0x7E（64-126）， &amp;#124;                         &amp;#124;    0xA1－0xFE（161-254） &amp;#8212;&amp;#8212;&amp;#8211;&amp;#124;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;-&amp;#124;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212; 二、对汉字进行hash 为了处理汉字的方便，在查找汉字的时候，我们通常会用到hash的方法，那怎么来确定一个汉字位置呢？这就和每种编码的排列有关了，这里主要给出一种hash函数的策略。 对于GB2312编码，设输入的汉字为GBword，我们可以采用公式(C1-176)*94 + (C2-161)确定GBindex。其中，C1表示第一字节，C2表示第二字节。具体如下： &lt;a href='http://blog.so8848.com/2011/09/3962.html'&gt;[...]&lt;/a&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/596885652/yahooblog/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/yahooblog/~7260371/596885652/5002429/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>编码</category><category>NLP</category><category>信息检索</category><category>Web</category><pubDate>Tue, 13 Sep 2011 12:52:19 +0800</pubDate><author>yezheng</author><comments>http://blog.so8848.com/2011/09/3962.html#comments</comments><guid isPermaLink="false">http://www.5yiso.cn/?p=3962</guid><dc:creator>yezheng</dc:creator><fs:srclink>http://blog.so8848.com/2011/09/3962.html</fs:srclink><fs:srcfeed>http://blog.so8848.com/feed</fs:srcfeed><fs:itemid>feedsky/yahooblog/~7260371/596885652/5002429</fs:itemid></item><item><title>高房价挟持了爱情和理想</title><link>http://item.feedsky.com/~feedsky/yahooblog/~7260371/556448721/5002429/1/item.html</link><wfw:commentRss>http://blog.so8848.com/2011/09/49743.html/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>虚高的房价，是否正挟持着你的爱情和理想？ 我始终感觉中国这种经济的发展对个人毫无意义，因为没有让人感觉生活变得快乐、自由，而是感觉不知道为什么在任劳任怨的奋斗着。心态稍微不好的人，就会感受巨大的躁动和不安。当爱情被放假所累，当理想变成房子，试问我们到底活着什么劲？有一个很好词来回答你，那就是“混呗”，虽然我们还饿不死，但理想早死了。纵然生活艰难，但总还有个希望，希望明天会更好。虽然这一切的一切我们都无法改变，但我们还有最后的自由&amp;#8211;保持好心态，随遇而安！ Sent to you by jeffye via Google Reader: 救房地产的措施为何都失灵了 via 时寒冰官方博客 by 时寒冰官方博客 on 2/24/09  BANG7F791CC78E6D35E58DA3B147XIANGUO 救房地产的措施为何都失灵了 ——驳把房地产作为“十大产业振兴规划”的谬论       时寒冰     从去年9月至今，有关刺激房地产的发展的政策一个接一个出台，数量之多，涉及面之广，没有任何一个行业可与之相比。但是，房地产行业依然处于垂死的状态，尽管一些地产大鳄仍在做着逆势涨价梦，尽管一些有着官员背景的所谓专家仍在鼓吹救市，但是，几乎每一个刺激性政策都失灵了。这到底是因为什么？     笔者研究房地产问题多年，翻阅了大量国家的资料，还没有发现哪一个国家的房地产问题，像当下的中国这样，如此牵动人心，如此令人忧虑。     衣食住行是生活的必需品，而在中国，在某种程度上，住房已经成为一种“崇拜物”。许多人找对象，已经不再是单纯地寻求爱情，还有房子，他们希望爱情背后立着一栋像样的房子，如果房子特别优秀，哪怕人不那么优秀甚至不优秀，哪怕缺少爱情的内涵，也能在角逐中胜出。当人们搀扶着房子走入婚礼的殿堂，我们不能不感叹，房子在顽强地改变着人们的生活。     不少大学生，渴望的不再是实现某个宏大的理想，而是拥有一套房子。房子取代理想成为终极目标的一个重要组成部分。最能代表一个民族未来发展动力的群体迷失了……      在钢筋水泥的丛林中迷失的不仅是爱情和理想，还有企业的价值观。遍数各个行业，能够像房地产这样带来暴利的，即使说不上绝无仅有，也可谓凤毛麟角。于是，不少企业放下自己的业务，投身到房地产开发行业当中去。那些没有能力做房地产开发的中小企业，则停下自己的业务，将资金大量投入到房地产领域炒房。当房子被提升到“崇拜物”的地位，我们不能不承认一个现实：一个民族，正在住房问题中迷失或沉沦。翻翻近年来我们的经济发展数据，除了房地产，还有什么？     房子为何成了奢侈品，成了“崇拜物”？最简单的答案就是：房价太高了。高房价挟持了爱情，挟持了年轻人的理想，也挟持了许多人的生活——“房奴”二字便是最恰如其分的写照。     房价为什么高？最简单的答案是建立在垄断基础上的掠夺。在中国房地产市场中，存在两大根深蒂固的垄断：一是地方政府对土地市场的垄断。二是开发商对房地产市场的垄断（当然包括对房屋开发的垄断）。前一个垄断使得权力成为唯一的地价主导者，导致地价不断上涨，后一个垄断则赋予了开发商强大的房屋定价权，导致房价不断上涨。     当然，这是从割裂的角度来看的。事实上，房价在垄断下的上涨，乃是两种垄断的结合，即房价上涨本身与政府垄断下的地价的上涨是有着最直接关系的。     两种垄断的结合，一不留神就演化成了官商勾结，而且，这种垄断逐渐得到了强化。1998年，我国发布了《国务院关于进一步深化城镇住房制度改革加快住房建设的通知》（简称23号文），明确“建立和完善以经济适用住房为主的住房供应体系”，城市80%以上的家庭由政府向他们供应经济适用房，但是，2003年8月12日，由原建设部起草的《关于促进房地产市场持续健康发展的通知》（简称18号文），把经济适用房由“住房供应主体”换成了“具有保障性质的政策性商品住房”。在既得利益集团的操纵下，住房供应从此基本落入了开发商手中。开发商垄断市场的局面被加强。     为什么建筑成本每平方米只有千元的楼房，要卖到2万、3万甚至5万？     这是由中国房地产行业的赤裸裸的掠夺性所决定的。     房地产垄断的结果，是赋予这个行业残酷的掠夺性。这种掠夺性并不仅仅体现在诸如暴力拆迁这样的问题当中，更体现在对民众所有权的剥夺方面。比如，根据宪法和法律，土地属于全民所有，而对于全民所有的土地，民众不仅在土地出让过程（比如出让与否、如何出让、出让给谁等）的决定权被剥夺，分享土地收益的权利也被剥夺，甚至，还必须花高价钱买回原本属于自己的土地使用权（包含在房价中），并且不能有任何减免。正是这种无本生利（且是暴利）的发展模式，给地方政府带来了滚滚收益，成就了房地产市场的繁荣，而这种建立在对民众血腥掠夺基础之上的繁荣注定是走不远的。事实上，正是这种掠夺营造出来的繁荣，蚕食了民众的财富，透支了民众的购买力，成为制约中国内需不振的一个根源性问题。     开发商群体是寄生在这种垄断之上的另一个食利阶层。作为中国特色的官商勾结的产物，当成功的开发商站在财富之巅俯视被掠夺、被压榨的芸芸众生，当无耻的被收买的文人为那些首先富起来的开发商树碑立传，当这种靠掠夺和腐败暴富的模式和暴富的人成为年轻一代学习的榜样，中国房地产业毁灭掉的何止是中国内需的根基！更有对中国道德根基的摧毁。     为什么人均年收入不足城镇人均年收入三分之一的广大农村，反而很好的解决了居住问题？就是因为，农村太穷，建立在掠夺基础之上的房地产发展模式无法在农村推行，所以，农民可以在自己的土地上盖房子——他们不必像城镇人口那样，凭空为自己拥有的土地额外花费昂贵的费用。对比之下，中国房地产业的掠夺性昭然若揭。    为什么房地产行业在民众心目中的地位最低劣，引发的抵触和憎恨情绪最为强烈？中国房地产发展的模式决定着，这是一个赤裸裸的以剥削和掠夺民众财富，以侵吞和摧毁民众幸福为根基的行业，是一个逐渐走向民众对立面、走向民生对立面、走向反动的行业。     中国房地产业所享受的资源已经非常丰富，尤其近段，刺激房地产的政策走马灯似的出台，为何效果了了？这实际上是掠夺走到尽头的一种最直观的信号，民众已经不堪高房价之重。低下的收入、残缺的社会保障机制、节节上涨的医疗教育等支出，已经使得伤痕累累的民众无力满足剥削者日益膨胀的胃口，无法再支撑起一个日益发展壮大的食利阶层。另一方面，所有的刺激房地产业的政策，都出自既得利益集团及其代言人之手，由于过分偏重自身利益而失去了可行性。     &lt;a href='http://blog.so8848.com/2011/09/49743.html/'&gt;[...]&lt;/a&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/556448721/yahooblog/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/yahooblog/~7260371/556448721/5002429/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>评论</category><category>MISC</category><category>房地产</category><pubDate>Tue, 13 Sep 2011 00:54:09 +0800</pubDate><author>gejun</author><comments>http://blog.so8848.com/2011/09/49743.html/#comments</comments><guid isPermaLink="false">http://blog.so8848.com/2009/02/49743.html</guid><dc:creator>gejun</dc:creator><fs:srclink>http://blog.so8848.com/2011/09/49743.html/</fs:srclink><fs:srcfeed>http://blog.so8848.com/feed</fs:srcfeed><fs:itemid>feedsky/yahooblog/~7260371/556448721/5002429</fs:itemid></item><item><title>java Map的访问方法备忘，Comparator例子</title><link>http://item.feedsky.com/~feedsky/yahooblog/~7260371/596885653/5002429/1/item.html</link><content:encoded>&lt;p&gt;&lt;font face=&quot;Verdana&quot;&gt;  &lt;/font&gt;&lt;font face=&quot;Verdana&quot;&gt;1.把Map中的Key或Value转化为数组&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=&quot;Verdana&quot;&gt;  &lt;/font&gt;&lt;font face=&quot;Verdana&quot;&gt;HashMap ssMap = new HashMap(); &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=&quot;Verdana&quot;&gt;  &lt;/font&gt;&lt;font face=&quot;Verdana&quot;&gt;Counter counters[] = new   Counter[ssMap.size()];&lt;br /&gt;
ssMap.values().toArray(counters); //转化，counters不需实例化&lt;br /&gt;
Arrays.sort(counters,new   DfComparator());//排序&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=&quot;Verdana&quot;&gt;  &lt;/font&gt;&lt;font face=&quot;Verdana&quot;&gt;2. Comparator 实例&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=&quot;Verdana&quot;&gt;  &lt;/font&gt;&lt;font face=&quot;Verdana&quot;&gt;继承Comparator也可以实现排序，但相对Comparable接口更加灵活，用不同的Comparator实例可以实现不同的排序方法&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=&quot;Verdana&quot;&gt;  &lt;/font&gt;&lt;font face=&quot;Verdana&quot;&gt;class DfComparator implements Comparator&lt;br /&gt;
{&lt;br /&gt;
public int   compare(Object o1, Object o2) {&lt;br /&gt;
// TODO Auto-generated method   stub&lt;br /&gt;
Counter c1 = (Counter)o1;&lt;br /&gt;
Counter c2 =   (Counter)o2;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=&quot;Verdana&quot;&gt;  &lt;/font&gt;&lt;font face=&quot;Verdana&quot;&gt;  return c2.df &amp;#8211; c1.df;&lt;br /&gt;
}&lt;br /&gt;
public boolean   equals(Object obj)&lt;br /&gt;
{&lt;br /&gt;
return   true;&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;}&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=&quot;Verdana&quot;&gt;  &lt;/font&gt;&lt;font face=&quot;Verdana&quot;&gt;3.Map访问语句备忘&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face=&quot;Verdana&quot;&gt;  &lt;/font&gt;&lt;font face=&quot;Verdana&quot;&gt; public static void print(Map map)&lt;br /&gt;
{&lt;br /&gt;
Set set =   map.entrySet();&lt;br /&gt;
Iterator iter =   set.iterator();&lt;br /&gt;
while(iter.hasNext())&lt;br /&gt;
{&lt;br /&gt;
Map.Entry   entry =   (Map.Entry)iter.next();&lt;br /&gt;
entry.getKey();&lt;br /&gt;
entry.getValue();&lt;br /&gt;
}&lt;br /&gt;
}&lt;/font&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/596885653/yahooblog/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/yahooblog/~7260371/596885653/5002429/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://blog.so8848.com/2011/09/3895.html/feed</wfw:commentRss><slash:comments>0</slash:comments><description>1.把Map中的Key或Value转化为数组 HashMap ssMap = new HashMap();  Counter counters[] = new Counter[ssMap.size()]; ssMap.values().toArray(counters); //转化，counters不需实例化 Arrays.sort(counters,new DfComparator());//排序 2. Comparator 实例 继承Comparator也可以实现排序，但相对Comparable接口更加灵活，用不同的Comparator实例可以实现不同的排序方法 class DfComparator implements Comparator { public int compare(Object o1, Object o2) { // TODO Auto-generated method stub Counter c1 = (Counter)o1; Counter c2 = (Counter)o2;   return c2.df &amp;#8211; c1.df; } public boolean equals(Object obj) { return true; &lt;a href='http://blog.so8848.com/2011/09/3895.html'&gt;[...]&lt;/a&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/596885653/yahooblog/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/yahooblog/~7260371/596885653/5002429/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>Map</category><category>Comparator</category><category>Java</category><pubDate>Tue, 13 Sep 2011 00:52:21 +0800</pubDate><author>yezheng</author><comments>http://blog.so8848.com/2011/09/3895.html#comments</comments><guid isPermaLink="false">http://www.5yiso.cn/articles/java-map%e7%9a%84%e8%ae%bf%e9%97%ae%e6%96%b9%e6%b3%95%e5%a4%87%e5%bf%98%ef%bc%8ccomparator%e4%be%8b%e5%ad%90.html</guid><dc:creator>yezheng</dc:creator><fs:srclink>http://blog.so8848.com/2011/09/3895.html</fs:srclink><fs:srcfeed>http://blog.so8848.com/feed</fs:srcfeed><fs:itemid>feedsky/yahooblog/~7260371/596885653/5002429</fs:itemid></item><item><title>[转]最新流行美语60句</title><link>http://item.feedsky.com/~feedsky/yahooblog/~7260371/556448722/5002429/1/item.html</link><wfw:commentRss>http://blog.so8848.com/2011/09/42514.html/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>[转]最新流行美语60句 2008/10/01 08:39 　 1. It&amp;#8217;s not like that. 不是那样的 　　It&amp;#8217;s not like that.这句话是用来辟谣的。当别人误会了一件事的来龙去脉，你就可以跟他说It&amp;#8217;s not like that.「不是那样的。」当然随着语气及情境的不同，It&amp;#8217;s not like that.这句话也有可能是你用来硬拗的藉口。 　　2. There is nothing good playing. 没好电影可看 　　这里的There&amp;#8217;s nothing good playing.是接着问句而来的，指的是「没有好电影可看」 　　同样的，若是电视上没有好节目可看，你就可以说There&amp;#8217;s nothing good on TV. 　　3. I&amp;#8217;ve gotten carried away. 我扯太远了。 　　get carried away字面上的意思是「被带走了」，那么被带走的是什么呢？就是心思。 　　当你或是他人说话的时候离了题，偏离主旨扯远了。你就可以用上这个表达法I&amp;#8217;ve / You&amp;#8217;ve gotten carried away. 　　4. Good thing&amp;#8230; 还好，幸好… &lt;a href='http://blog.so8848.com/2011/09/42514.html/'&gt;[...]&lt;/a&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/556448722/yahooblog/feedsky/s.gif?r=http://item.feedsky.com/~feedsky/yahooblog/~7260371/556448722/5002429/1/item.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>Canada Related</category><category>英语</category><category>美语</category><pubDate>Tue, 13 Sep 2011 00:48:52 +0800</pubDate><author>gejun</author><comments>http://blog.so8848.com/2011/09/42514.html/#comments</comments><guid isPermaLink="false">http://www.5yiso.cn/2008/10/42514.html</guid><dc:creator>gejun</dc:creator><fs:srclink>http://blog.so8848.com/2011/09/42514.html/</fs:srclink><fs:srcfeed>http://blog.so8848.com/feed</fs:srcfeed><fs:itemid>feedsky/yahooblog/~7260371/556448722/5002429</fs:itemid></item></channel></rss>
