linux find命令查找目录及文件夹_4

查看文件内容—cat/more/less/head/tail (只能查看文本文件)

cat
[root@localhost dict]# cat -n /etc/fstab
>>>查看行号并且会给每一行增加行号 (适用于文件内容较少)

[root@localhost etc]# cat /etc/redhat-release           --查看系统的发行版信息
Red Hat Enterprise Linux Server release 7.1 (Maipo)

more/less(分页显示文件):

[root@localhost etc]# less /usr/share/dict/words 

[root@localhost etc]# more /usr/share/dict/words 

head/tail

[root@localhost etc]# head -n 3 /etc/passwd     >>>默认查看文件前10行的内容

[root@localhost etc]# tail -n 3 /etc/passwd     >>>默认查看文件后10行的内容

查看文件的类型:

[root@localhost etc]# file /etc/passwd

查看系统命令所在的目录

[root@localhost bin]# which ls 

| 管道符 :>>>前面命令的结果作为参数传递到后面的命令

[root@localhost bin]# head -n 5 /home/oracle/.bashrc | tail -n 1

查找文件或目录 :

find 路径 查找方式

按文件名称查找:

[root@localhost etc]# find /etc/ -name "*.conf"

[root@localhost etc]# find /etc/ -name "*.conf" | wc -l   

按文件大小查找:
[root@localhost etc]# find /etc/ -size +1M >>>查看/etc/大于1M的文件 +表示大于 — 表示小于

按文件的修改时间查找:
[root@localhost etc]# find -mtime +7 >>>查看7天之前修改过的文件
[root@localhost etc]# find -mtime -7 >>>查看7天之内修改过的文件

按文件的类型查找:

[root@localhost ~]# find /dev/ -type  l

[root@localhost ~]# find /etc/ -mtime -7 -a -size +100k >>>查看7天之内修改过并且大于100k的文件 a:and 并且
[root@localhost test]# find /home/test/ -name "*.jgp" -exec rm -rf {} \; >>>删除以jpg结尾的文件
[root@localhost test]# find /home/test/ -name "*.txt" -exec cp {} /home/test/huge/ \; >>>找到以txt结尾的文件并复制到其他路径下

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值