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

<channel>
	<title>碧云涛小屋 &#187; bash</title>
	<atom:link href="http://blog.axqd.net/tags/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.axqd.net</link>
	<description>by aXqd</description>
	<lastBuildDate>Sat, 17 Jul 2010 16:42:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<atom:link rel='hub' href='http://blog.axqd.net/?pushpress=hub'/>
		<item>
		<title>BASH取得脚本所在路径</title>
		<link>http://blog.axqd.net/2009/12/22/get-script-path-in-bash/</link>
		<comments>http://blog.axqd.net/2009/12/22/get-script-path-in-bash/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 09:08:11 +0000</pubDate>
		<dc:creator>axqd</dc:creator>
				<category><![CDATA[自由世界]]></category>
		<category><![CDATA[bash]]></category>

		<guid isPermaLink="false">http://blog.axqd.net/?p=758</guid>
		<description><![CDATA[脚本所在路径通常来说，比pwd好用得多。以前，总是直接dirname $0，或者在perl里从__FILE__里取。今天又要写这个，看恶心了，想起bash自己就能做这种事情，但不记得语法了。于是google了一下&#8221;bash string manipulate&#8221;。 果然很好很强大：http://tldp.org/LDP/abs/html/string-manipulation.html 用得上的是这段： ${string%substring} Deletes shortest match of $substring from back of $string. 于是${0%/*}把末尾&#8217;/'以后的全删掉就行了。 当然，这是相对于pwd的路径，不过已经够用了。]]></description>
			<content:encoded><![CDATA[<p>脚本所在路径通常来说，比pwd好用得多。以前，总是直接dirname $0，或者在perl里从__FILE__里取。今天又要写这个，看恶心了，想起bash自己就能做这种事情，但不记得语法了。于是google了一下&#8221;bash string manipulate&#8221;。</p>
<p>果然很好很强大：<a href="http://tldp.org/LDP/abs/html/string-manipulation.html">http://tldp.org/LDP/abs/html/string-manipulation.html</a></p>
<p>用得上的是这段：<br />
${string%substring}<br />
Deletes shortest match of $substring from back of $string.</p>
<p>于是${0%/*}把末尾&#8217;/'以后的全删掉就行了。<br />
当然，这是相对于pwd的路径，不过已经够用了。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.axqd.net/2009/12/22/get-script-path-in-bash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
