Linux查找命令 - which - find

1、which 命令

查找命令

语法:which 要查找的命令

        无需选项,只需要参数表示查找哪个命令

[shui@xiaored ~]$ which ll
alias ll='ls -l --color=auto'
        /bin/ls
[shui@xiaored ~]$ which cd
/bin/cd
[shui@xiaored ~]$ 

2、find 命令

用于查找文件

按文件名查找:

语法:find 起始路径 -name "被查找文件名"

        支持通配符,星号:*,匹配任意内容(包括),可以用作模糊查询。

    相对路径
[shui@xiaored ~]$ find -name "demo.txt"
./demo.txt

    绝对路径
[shui@xiaored ~]$ find /home/shui/ -name "newfile"
/home/shui/newfile

使用通配符 *
    相对路径
[shui@xiaored ~]$ find -name "demo*"
./demo.txt
./demo01.txt
[shui@xiaored ~]$
    绝对路径
[shui@xiaored ~]$ find /home/shui/ -name "demo*"
/home/shui/demo.txt
/home/shui/demo01.txt

按文件大小查找文件

语法:find 起始路径 -size +/-n[kMG]

        +、- 表示大于和小于

        n 表示大小数字

        kMG表示大小单位,k(小写字母)表示KB,M表示MB,G表示GB;

        不写起始路径,就查找当前路径下的文件;查到默认包含隐藏文件;

[shui@xiaored ~]$ ll -lh
总用量 16M
-rw-rw-r--. 1 shui shui  16M 8月  29 14:56 demo01.txt
-rw-rw-r--. 1 shui shui 1.6K 8月  24 17:36 demo.txt
drwxrwxr-x. 2 shui shui    6 8月  21 15:34 newfile
[shui@xiaored ~]$ find -size +10M
./demo01.txt
[shui@xiaored ~]$ 

[shui@xiaored ~]$ find -size -10M
.
./.mozilla
./.mozilla/extensions
./.mozilla/plugins
./.bash_logout
./.bash_profile
./.bashrc
./newfile
./demo.txt
./.bash_history
./.viminfo

[shui@xiaored ~]$ ll -lh
总用量 16M
-rw-rw-r--. 1 shui shui  16M 8月  29 14:56 demo01.txt
-rw-rw-r--. 1 shui shui 1.6K 8月  24 17:36 demo.txt
drwxrwxr-x. 2 shui shui    6 8月  21 15:34 newfile
[shui@xiaored ~]$

账户、权限需要注意;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值