〔Bash〕pastebincl快捷提交脚本
Linux下一内置代理功能的优秀广播收听软件Clementine

Linux下递归列出仅所有常规文件或文件夹路径的方法

λ posted @ 2012年9月20日 15:26 in Mixture with tags bash linux tutorial , 22067 阅读

混蛋的,好不容易才知道,立刻发篇博文说一下……囧

## 只列出常规文件
find ./ -type f

## 只列出文件夹
find ./ -type d

find的man page介绍太长了,眼花缭乱(用zsh的可无视= =;)!百度和GOOGLE的结果也太烂了,几乎全是ls方法。

 

既然用到find了,就不得不提它的另一个功能了:

## 对找到的所有文件进行批处理

find . -type f -exec chmod 644 {} \; # 后面的\;必须的,表示按行输出

find . -type d -exec chmod 755 {} \; # {} 表示找到的文件路径

好了,暂时介绍完毕,大家还是继续man find去吧……


本網站無註明「轉載」的著作均由Jak Wings製作 CC BY-NC-SA 2.5
Creative Commons 保持署名-相同方式分享 2.5

Avatar_small
依云 说:
Sep 20, 2012 05:15:12 PM

用 zsh 嘛,输入 find - 然后按 Tab 看看有什么选项,选择 -type 后再按 Tab 看看有那些参数,分别表示什么意思:
>>> find -type
-- file type --
b -- block special file
c -- character special file
d -- directory
f -- normal file
l -- symbolic link
p -- named pipe
s -- socket

Avatar_small
λ 说:
Sep 21, 2012 01:16:35 AM

-_-;; 原来zsh这么强大的啊……解释都有……

Avatar_small
依云 说:
Sep 21, 2012 09:50:36 AM

是啊,很多时候都不用查手册了 :-)

Blade 说:
Jan 09, 2013 11:57:30 AM

如果只是递归列出全部的话
ls -R
就可以了。

find 的强大在于丰富过滤条件,以及找到之后的动作(-exec 参数 以及 管道通向 xargs 等方法)。

λ 说:
Jan 25, 2013 11:58:57 PM

嗯,为了只列出文件或文件夹的路径我在网上搜索了好久……只有find是最方便最完美的。
话说我不玩微博,叫人情何以堪……

SSO ID 说:
Aug 04, 2022 02:14:16 AM

SSO stands for Single Sign On and SSO Rajasthan for any citizen to create their digital identity. According to their official website, more than 18672702 identities have been create from their official website. There are different benefits of being a part of this online platform out of which the primary one is to be under the Jan Aadhaar scheme and benefits. SSO ID Along with that you can also get benefits from schemes such as Bhamashah but before you do, you have to create your account and in the below guide we have explained the exact steps you need to follow, and if any queries, you may contact SSO customer care.

AP 1st Inter Model P 说:
Aug 25, 2022 07:31:43 PM

Board of Intermediate Education AP (BIEAP) Offer Last Year Important Model Question Paper 2023 for the Following Subjects in Part 1 English, In Part 2 Second Languages ​​Like Telugu, Hindi, Urdu, AP 1st Inter Model Paper 2023 Arabic, French, Tamil, Kannada , Oriya, and Marathi are Provided. In Part 3 Optional Subjects Like Mathematics, Physics, Chemistry, Botany, Zoology, Commerce, Economics, Civics, History, Psychology, Public Administration, Logic, Sociology, Geography, Geology and Modern Language Subjects Like English , Telugu, Hindi, and Urdu are Provided.

Emma 说:
Jan 21, 2023 10:12:54 PM

Finding all the regular files and folder paths under Linux can be tricky, but the find command makes it much easier. With lupus treatment just two simple commands, you can easily list out all the files and folders. Simply use 'find ./ -type f' to list all regular files and 'find ./ -type d' to list all folders. The find command can be a lifesaver when it comes to quickly listing paths on Linux, so make sure to keep it in your toolkit!

Tenda 说:
Feb 03, 2023 12:45:27 AM

The popular brand Tenda supplies various wireless routers which well known for easy configuration of the WiFi network. Once a new Router bought, one should make it ready to configure such that their LAN connection does move to WiFi to used by multiple devices. Tenda Tenda is the most preferred brand in customer premises wireless equipment due to its good range and stable connection. This difference in Bandwidth does allow the WiFi Router to handle better internet for any kind of bandwidth requested.

25penny.com 说:
Apr 25, 2023 02:26:49 PM

During your visit to our website, there are chances to collect more information without making you directly acknowledged. Website does collect your personal information such as name, identity, Gender and would also collect the geographic location. During your visit to our website, there are chances to collect more information without 25penny.com making you directly acknowledged. Website does collect your personal information such as name, identity, Gender and would also collect the geographic location.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter