<?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; linux</title>
	<atom:link href="http://dwfeng.net/blog/tag/linux/feed" rel="self" type="application/rss+xml" />
	<link>http://dwfeng.net/blog</link>
	<description>self.生活{&#124;x&#124; 快乐 &#38;&#38; 幸福}</description>
	<lastBuildDate>Tue, 16 Jun 2009 15:56:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>在Shell里列出文件名和路径的几种方法</title>
		<link>http://dwfeng.net/blog/2008/03/27/list_filename_path_in_shell.html</link>
		<comments>http://dwfeng.net/blog/2008/03/27/list_filename_path_in_shell.html#comments</comments>
		<pubDate>Thu, 27 Mar 2008 12:02:28 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://dwfeng.net/blog/2008/03/27/%e5%9c%a8shell%e9%87%8c%e5%88%97%e5%87%ba%e6%96%87%e4%bb%b6%e5%90%8d%e5%92%8c%e8%b7%af%e5%be%84%e7%9a%84%e5%87%a0%e7%a7%8d%e6%96%b9%e6%b3%95/</guid>
		<description><![CDATA[关于如何列出指定路径里的文件和相对路径，这个问题看上去很简单。其实还是有一些技巧的。简单的用ls命令得出的输出格式，有的时候不是我们想要的。 用&#8221;ls -R&#8221;显示出来的结果格式是这样： $ ls -R sources sources: 1.2 1.txt 2.txt one temp tmp sources/1.2: sources/one: two sources/one/two: x.txt y.txt z.txt sources/temp: 虽然这样的格式，看起来比较清晰，不过要是进一步做处理的话就不太方便了。比如，我们要把一个目录的文件和它所在的路径都找出来，并且不显示空目录的话，用&#8221;ls -R&#8221;就不行了。 这是我们就可以用find命令。 $ find ./sources ! -type d -print ./sources/1.txt ./sources/2.txt ./sources/one/two/x.txt ./sources/one/two/y.txt ./sources/one/two/z.txt ./sources/tmp 这种格式，处理起来就方便多了。 下面是用find来显示文件路径和文件名的几种常用组合： find / -type d -print (只显示路径) find / -type l -print (只显示soft link) find / [...]]]></description>
			<content:encoded><![CDATA[<p>关于如何列出指定路径里的文件和相对路径，这个问题看上去很简单。其实还是有一些技巧的。简单的用ls命令得出的输出格式，有的时候不是我们想要的。</p>
<p>用&#8221;ls -R&#8221;显示出来的结果格式是这样：</p>
<p><strong>$ ls -R sources<br />
sources:<br />
1.2 1.txt 2.txt one temp tmp<br />
sources/1.2:<br />
sources/one:<br />
two<br />
sources/one/two:<br />
x.txt y.txt z.txt<br />
sources/temp:</strong></p>
<p>虽然这样的格式，看起来比较清晰，不过要是进一步做处理的话就不太方便了。比如，我们要把一个目录的文件和它所在的路径都找出来，并且不显示空目录的话，用&#8221;ls -R&#8221;就不行了。</p>
<p>这是我们就可以用find命令。</p>
<p><strong>$ find ./sources ! -type d -print<br />
./sources/1.txt<br />
./sources/2.txt<br />
./sources/one/two/x.txt<br />
./sources/one/two/y.txt<br />
./sources/one/two/z.txt<br />
./sources/tmp</strong></p>
<p>这种格式，处理起来就方便多了。</p>
<p>下面是用find来显示文件路径和文件名的几种常用组合：</p>
<p><strong>find / -type d -print (只显示路径)<br />
find / -type l -print (只显示soft link)<br />
find / -type b -print (只显示block special files)<br />
find / -type f -print (只显示普通的文件)</strong></p>
<p>另外，也可以用！来加以修饰，</p>
<p><strong>find / ! -type d -print (列出目录以外的所有东西)</strong></p>
<p>参考：</p>
<p><a href="http://www.unix.com/unix-advanced-expert-users/35349-list-all-files-full-path-file.html"><strong>http://www.unix.com/unix-advanced-expert-users/35349-list-all-files-full-path-file.html</strong></a></p>
]]></content:encoded>
			<wfw:commentRss>http://dwfeng.net/blog/2008/03/27/list_filename_path_in_shell.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
