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

<channel>
	<title>某人的栖息地 &#187; shell</title>
	<atom:link href="http://www.ooso.net/tag/shell/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ooso.net</link>
	<description>Linux + Apache + Mysql + Php + Flash</description>
	<lastBuildDate>Thu, 19 Jan 2012 01:21:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>mac下的tree命令</title>
		<link>http://www.ooso.net/archives/564</link>
		<comments>http://www.ooso.net/archives/564#comments</comments>
		<pubDate>Mon, 22 Nov 2010 12:34:50 +0000</pubDate>
		<dc:creator>Volcano</dc:creator>
				<category><![CDATA[common]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[tree]]></category>

		<guid isPermaLink="false">http://www.ooso.net/?p=564</guid>
		<description><![CDATA[在默认安装安装的mac下没有找到tree命令，找了一下原来有个比较流氓的解决办法：
find . -print &#124; sed -e 's;[^/]*/;&#124;____;g;s;____&#124;; &#124;;g'
这个命令行跑起来类似平常tree的效果，比如：
.

				<span class="readmore"><a href="http://www.ooso.net/archives/564" title="mac下的tree命令">阅读全文（881字）</a></span>]]></description>
			<content:encoded><![CDATA[<p>在默认安装安装的mac下没有找到tree命令，找了一下原来有个比较流氓的解决办法：</p>
<pre><code>find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'</code></pre>
<p>这个命令行跑起来类似平常tree的效果，比如：</p>
<pre><code>.
|____extra
| |____httpd-autoindex.conf
| |____httpd-dav.conf
| |____httpd-default.conf
| |____httpd-info.conf
| |____httpd-languages.conf
| |____httpd-manual.conf
| |____httpd-mpm.conf
| |____httpd-multilang-errordoc.conf
| |____httpd-ssl.conf
| |____httpd-userdir.conf
| |____httpd-vhosts.conf
|____httpd.conf
|____magic
|____mime.types
|____original
| |____extra
| | |____httpd-autoindex.conf
| | |____httpd-dav.conf
| | |____httpd-default.conf
| | |____httpd-info.conf
| | |____httpd-languages.conf
| | |____httpd-manual.conf
| | |____httpd-mpm.conf
| | |____httpd-multilang-errordoc.conf
| | |____httpd-ssl.conf
| | |____httpd-userdir.conf
| | |____httpd-vhosts.conf
| |____httpd.conf
|____other
| |____bonjour.conf
| |____php5.conf
|____users</code></pre>
<p>写一个alias到~/.bash_profile里，就更方便了:</p>
<pre><code>alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ooso.net/archives/564/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>混合使用SQL和shell命令</title>
		<link>http://www.ooso.net/archives/439</link>
		<comments>http://www.ooso.net/archives/439#comments</comments>
		<pubDate>Tue, 01 Jul 2008 01:19:57 +0000</pubDate>
		<dc:creator>Volcano</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.ooso.net/index.php/archives/439</guid>
		<description><![CDATA[mysql下可以用批处理模式运行SQL，比如:
shell&#62; mysql -h host -u user -p &#60; batch-file.sql
Enter password: ********
但是平常往往需要在执行sql的同时，运行一些shell脚本进行进一步计算，保存日志之类的。这个可以靠mysql的system命令来实现，例如：

				<span class="readmore"><a href="http://www.ooso.net/archives/439" title="混合使用SQL和shell命令">阅读全文（603字）</a></span>]]></description>
			<content:encoded><![CDATA[<p>mysql下可以用批处理模式运行SQL，比如:</p>
<pre><code>shell&gt; mysql -h host -u user -p &lt; batch-file.sql
Enter password: ********</code></pre>
<p>但是平常往往需要在执行sql的同时，运行一些shell脚本进行进一步计算，保存日志之类的。这个可以靠<a href="/?tag=mysql">mysql</a>的system命令来实现，例如：</p>
<pre><code># Mixing shell commands and SQL queries in batch mode- demo script
use test;
#INSTALL PLUGIN example SONAME 'ha_example.so'; #Ignore statement
system cp /tmp/mysqld.trace logs/init.trace # Shell commands prefixed with a 'system'
create table new4(num integer) engine=EXAMPLE;
system cp /tmp/mysqld.trace logs/after_create.trace # Shell commands prefixed with a 'system'
system diff logs/init.trace logs/after_create.trace # Shell commands prefixed with a 'system'</code></pre>
<h3>注意</h3>
<ul>
<li>system命令只在类unix操作系统上有效。</li>
<li>可以在存储过程中使用system。</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.ooso.net/archives/439/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>在命令行里执行mysql的sql</title>
		<link>http://www.ooso.net/archives/429</link>
		<comments>http://www.ooso.net/archives/429#comments</comments>
		<pubDate>Mon, 23 Jun 2008 03:05:39 +0000</pubDate>
		<dc:creator>Volcano</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.ooso.net/?p=429</guid>
		<description><![CDATA[平常执行sql，需要登录到mysql的shell下，然后再执行。比如：
$ /usr/bin/mysql -u root
mysql&#62; select * from users;
但是如果写一点简单的脚本，也可以在命令行下直接运行sql并显示结果，比如：

				<span class="readmore"><a href="http://www.ooso.net/archives/429" title="在命令行里执行mysql的sql">阅读全文（204字）</a></span>]]></description>
			<content:encoded><![CDATA[<p>平常执行sql，需要登录到<a href="/?tag=mysql">mysql</a>的shell下，然后再执行。比如：</p>
<pre><code>$ /usr/bin/mysql -u root
mysql&gt; select * from users;</code></pre>
<p>但是如果写一点简单的脚本，也可以在命令行下直接运行sql并显示结果，比如：</p>
<pre><code>$ cat executemysql.sh
#!/bin/sh

qry=$1;

echo "Executing the following query"
echo "$qry"

mysql -u root &lt;&lt; eof
$qry
eof</code></pre>
<p>运行一下:</p>
<pre><code>$ ./executemysql.sh "select id,name,age from test.users limit 2"
Executing the following query
select id,name,age from test.users limit 2
id name age
3 john 20
4 tom 21</code></pre>
<p>原文：<a href="http://unstableme.blogspot.com/2008/06/execute-mysql-from-bash-script.html">Execute mysql from bash script</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ooso.net/archives/429/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

