免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 2991 | 回复: 10
打印 上一主题 下一主题

如何查找一个子目录的路径? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-02-09 11:20 |只看该作者 |倒序浏览
我知道那个子目录的路径,但是不知道上几级目录,怎么样能查找到该目录的路径呢?

3q3q

论坛徽章:
0
2 [报告]
发表于 2004-02-09 11:30 |只看该作者

如何查找一个子目录的路径?

。。。。。。。。。。

pwd
为什么删偶的帖子啊

论坛徽章:
0
3 [报告]
发表于 2004-02-09 14:41 |只看该作者

如何查找一个子目录的路径?

没有好方法找吗?

论坛徽章:
0
4 [报告]
发表于 2004-02-09 14:46 |只看该作者

如何查找一个子目录的路径?

[语法]: find    路径名...    表达式
   [说明]: find 命令递归地遍历指定路径下的每个文件和子目录,看该文件是否能使表达式值为真,以下 n 代表一个十进制整数,+n 代表打印 n , -n 代表小于 n ,下面是合法表达式说明:
        -name  模式           文件名与模式匹配则为真,(\ 为转意符)
          -perm  [-]八进制数        文件存取模式与八进制数相同则为真若有- 选项,则文件存
                           取模式含有八进制数规定模式即为真
        -size  n[c]                文件块长度为 n 则真(一块为512字节),若
                                有c 选项,则文件字节长度为 n 则真
        -atime n                若文件的最近访问时间为 n 天前则为真,
                                find 命令将改变其访问的目录的访问时间
        -mtime n                若文件的最近修改时间为 n 天前则为真
        -ctime n                若文件状态为 n 天前改变则为真
        -exec 命令  { }\;        若命令返回值为0则真,{ }内为命令参数,
                                此命令必须以 \; 为结束
        -ok         命令    { }\;        与 exec 相同,只是在命令执行前先提示,若
                                回答 y 则执行命令
        -print                显示输出使表达式为真的文件名
        -newer 文件        若文件的访问时间比newer 指定的文件新则真
        -depth                先下降到搜索目录的子目录,然后才至其自身
        -mount                仅查找包含指定目录的文件系统
        -local                文件在当前文件系统时为真
        -type  c                文件类型为 c 则真,c 取值可为 b(块文件) c (字符文件)
                           d(目录) l (符号链接) p (命名管道) f (普通文件)
        \(  表达式 \)   表达式为真则真
        -links  n                文件链接数为 n 时为真
        -user   用户                当文件属于用户时为真,用户可用数字表示UID
        -nouser                  当文件不属于 /etc/passwd 中的一个用户时为真
        -group  文件组        当文件属于文件组时为真,文件组可用数字表示GID
        -nogroup                当文件不属于 /etc/group 中的一个组时为真       
        -fstype   类型        当文件所属文件系统类型为指定类型时真
        -inum    n                当文件 i 节点号为 n 时为真
        -prune                   当目录名与模式匹配时,不再搜索其子目录
                                  可以用逻辑操作符将简单表达式连接成复杂表达式
        逻辑操作符有 ! 表示非操作, -o  表示或操作,两个表达式并列则表示
        与操作
   [例子]:
        find / -name find* -print
                从根目录开始搜索文件名如 find* 的文件并显示之
        find ./ -exec sleep{1}\; -print
                          每秒显示一个当前目录下的文件
        find $HOME \(-name a.out -o -name '*.o' \) -atime +7  -exec   rm {} \;
        从$HOME目录开始搜索,删除所有文件名为a.out 或 *.o 且访问时间在7天前的文件

论坛徽章:
0
5 [报告]
发表于 2004-02-09 14:59 |只看该作者

如何查找一个子目录的路径?

这是查找文件的吧?能查找子目录吗?

论坛徽章:
0
6 [报告]
发表于 2004-02-09 15:00 |只看该作者

如何查找一个子目录的路径?

find 命令递归地遍历指定路径下的每个文件和子目录

论坛徽章:
0
7 [报告]
发表于 2004-02-09 16:39 |只看该作者

如何查找一个子目录的路径?

Pay attention , Just at the beginning it is "find files"
User Commands                                             find(1)

NAME
     find - find files

SYNOPSIS
     find path ...  expression

DESCRIPTION
     The find utility recursively descends the directory  hierar-
     chy for each path seeking files that match a Boolean expres-
     sion written in the primaries given below.

     find will be able to descend to arbitrary depths in  a  file
     hierarchy  and  will not fail due to path length limitations
     (unless a path operand specified by the application  exceeds
     PATH_MAX requirements).

OPERANDS
     The following operands are supported:

     path  A path name of  a  starting  point  in  the  directory
           hierarchy.

     expression
           The first argument that starts with a -, or is a !  or
           a  (, and all subsequent arguments will be interpreted
           as an expression made up of  the  following  primaries
           and  operators.   In  the  descriptions, wherever n is
           used as a primary argument, it will be interpreted  as
           a decimal integer optionally preceded by a plus (+) or
           minus (-) sign, as follows:

           +n    more than n

           n     exactly n

           -n    less than n

  Expressions
     Valid expressions are:

     -atime n
           True if the file was accessed n days ago.  The  access
           time of directories in path is changed by find itself.

     -cpio device
           Always true; write the current file on device in  cpio
           format (5120-byte records).

     -ctime n
           True if the file's status was changed n days ago.

     -depth
           Always true; causes descent of the directory hierarchy
           to  be  done  so  that  all entries in a directory are
           acted on before the directory itself.
            This can be useful when find is used with cpio(1)  to
           transfer  files  that  are  contained  in  directories
           without write permission.

     -exec command
           True if the executed command returns a zero  value  as
           exit status.  The end of command must be punctuated by
           an  escaped  semicolon.   A  command  argument  {}  is
           replaced by the current path name.

     -follow
           Always true; causes symbolic  links  to  be  followed.
           When following symbolic links, find keeps track of the
           directories visited so that  it  can  detect  infinite
           loops;  for example, such a loop would occur if a sym-
           bolic link pointed to  an  ancestor.  This  expression
           should not be used with the -type l expression.

     -fstype type
           True if the filesystem to which the file belongs is of
           type type.

     -group gname
           True if the file belongs to the group gname. If  gname
           is numeric and does not appear in the /etc/group file,
           or in the NIS/NIS+ tables, it is taken as a group ID.

     -inum n
           True if the file has inode number n.

     -links n
           True if the file has n links.

     -local
           True if the file system type is not a remote file sys-
           tem  type as defined in the /etc/dfs/fstypes file. nfs
           is used as the default remote filesystem type  if  the           /etc/dfs/fstypes file is not present. Note that -local
           will descend the hierarchy of  non-local  directories.
           See EXAMPLES for an example of how to search for local
           files without descending.

     -ls   Always true; prints current path  name  together  with
           its  associated  statistics.  These  include  (respec-
           tively):
... ...

论坛徽章:
0
8 [报告]
发表于 2004-02-09 16:48 |只看该作者

如何查找一个子目录的路径?

目录也是个文件,这不是238基本概念吗?另外,去试试不就都知道了?

论坛徽章:
0
9 [报告]
发表于 2004-02-09 16:59 |只看该作者

如何查找一个子目录的路径?

o, 我错了,我再试试。

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
10 [报告]
发表于 2004-02-09 17:05 |只看该作者

如何查找一个子目录的路径?

你可以用du -k试试,虽说du 本不是遍历文件的,但是它可以把每个目录列出来,8过只能从向下,反着好像8行
呵呵
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP