find命令/文件名后缀
2.23/2.24/2.25 find命令
2.26 文件名后缀
find
搜索文件的命令:
which 它是从环境变量中找:
[root@centos_1 ~]# which ls
alias ls='ls --color=auto'
/usr/bin/ls
环境变量:
[root@centos_1 ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/tmp/:/root/bin
whereis ls 查看文件的位置,但是查找的不全:
[root@centos_1 ~]# whereis ls
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz
跟whereis 很像的还有一个mlocate:
安装mlocate
yum install -y mlocate
更新一下文件数据库才行:
[root@centos_1 ~]# updatedb
查找: locate finename
locate xiaobofile
find 查找:find 路径 -name 文件名
[root@centos_1 ~]# find /etc/ -name "sshd_config"
/etc/ssh/sshd_config
find 路径 -type 文件类型 -name 文件名
查找目录文件:-type d
find /etc/ -type d -name "sshd*"
[root@centos_1 ~]# find /etc/ -type d -name "ssdh*"
查找文件类型:-type f
[root@centos_1 ~]# find /etc/ -type f -name "ssdh*"
都可以查找文件类型:
-type l 软链接文件
-type d 目录文件
-type f (-) 文件
-type c 字符设备文件
-type s socket文件
-type b block块文件(b文件)
终端操作命令:
ctrl + l 光标移动到第一行;
ctrl + d 登出(没有输入命令下)
ctrl + u 删除光标前面的字符
ctrl + d 删除光标后面的字符
ctrl + a 光标移到到开头
ctrl + e 光标移动到末尾
stat 查看文件具体信息 : 3个time:atime mtime ctime 比ls更清楚:
[root@centos_1 ~]# stat anaconda-ks.cfg.1
文件:"anaconda-ks.cfg.1"
大小:3360 块:8 IO 块:4096 普通文件
设备:803h/2051d Inode:67172258 硬链接:1
权限:(0600/-rw-------) Uid:( 1000/ xiaobo) Gid:( 1000/ xiaobo)
最近访问:2017-11-17 08:43:29.453703489 +0800
最近更改:2017-11-17 08:43:29.453703489 +0800
最近改动:2017-11-20 20:48:05.866081882 +0800
创建时间:-
文件名后缀
更改为英文:LANG=en
[root@centos_1 ~]# LANG=en
[root@centos_1 ~]# stat anaconda-ks.cfg.1
File: 'anaconda-ks.cfg.1'
Size: 3360 Blocks: 8 IO Block: 4096 regular file
Device: 803h/2051d Inode: 67172258 Links: 1
Access: (0600/-rw-------) Uid: ( 1000/ xiaobo) Gid: ( 1000/ xiaobo)
Access: 2017-11-17 08:43:29.453703489 +0800
Modify: 2017-11-17 08:43:29.453703489 +0800
Change: 2017-11-20 20:48:05.866081882 +0800
Birth: -
Access 最近访问atime
Modify最近修改mtime
Change最近改动ctime
查找1天以内最近修改的文件
find / -type f -mtime -1 (-mtime最近修改,-1一天以内)
[root@centos_1 ~]# find /etc/ -type f -mtime -1
/etc/resolv.conf
/etc/group
/etc/gshadow
/etc/passwd
/etc/passwd-
/etc/shadow
/etc/shadow-
/etc/ld.so.cache
/etc/group-
/etc/gshadow-
/etc/tuned/active_profile
find / -type f -atime -1 一天内最近访问的文件
find / -type f -ctime -1 一天内最近改动的文件
查找.conf类型的 最近1天修改的文件:
[root@centos_1 ~]# find /etc/ -type f -mtime -1 -name ".conf"
查找最近1天内修改的文件,或者最近一天内修改的文件 文件类型是.conf的(其中-o是或者)
[root@centos_1 ~]# find /etc/ -type f -o -mtime -1 -o -name ".conf"
关于查找硬链接文件:
[root@centos_1 ~]# ln 1.txt /tmp/1.txt.bak
[root@centos_1 ~]# ls -l /tmp/1.txt.bak
-rw-r--r-- 2 root root 103 11月 21 04:51 /tmp/1.txt.bak
[root@centos_1 ~]# ls -i !$
ls -i /tmp/1.txt.bak
67246931 /tmp/1.txt.bak
[root@centos_1 ~]#
查找文件的硬链接:
find / -inum 67246931(后面数字是inode号)
[root@centos_1 ~]# find / -inum 67246931
/root/1.txt
/tmp/1.txt.bak
查找一个小时内(60分钟内)的文件:
[root@centos_1 ~]# find /root/ -type f -mmin -60
查找一个小时以内的文件并同时执行ls -l 列出详细信息
[root@centos_1 ~]# find /root/ -type f -mmin -60 -exec ls -l {} \;
其中{}表示列出的列表;
查找一个小时内的文件并同时执行mv进行重命名
[root@centos_1 ~]# find /root/ -type f -mmin -60 -exec mv {} {}.bak \;
[root@centos_1 ~]# find /root/ -type f -mmin -60
/root/1.txt.bak
查找文件大于10k的文件,并同时列出
[root@centos_1 ~]# find /root/ -size +10k -exec ls -lh {} \;
-rw-------. 1 root root 11K 11月 21 07:11 /root/.bash_history
查找文件小于10K的文件,并同时列出:
[root@centos_1 ~]# find /root/ -size -10k -exec ls -lh {} \;
查找文件大于10M,并同时列出
[root@centos_1 ~]# find /root/ -size -10M -exec ls -lh {} \;
总结:
find -type -mtime -mmin -size -o (或者) -exec -name
修改的 分钟 大小 或者 执行 名字
find命令/文件名后缀的更多相关文章
- Find命令、文件名后缀、Linux和Windows互传文件 使用介绍
第2周第5次课(3月30日) 课程内容: 2.23/2.24/2.25 find命令2.26 文件名后缀 2.27 Linux和Windows互传文件 find命令 文件查找: 1.which(一般用 ...
- Linux CentOS7 VMware find命令、文件名后缀
一.find命令 Linux系统中的 find 命令在查找文件时非常有用而且方便.它可以根据不同的条件来查找文件,例如权限.拥有者.修改日期/时间.文件大小等等.在这篇文章中,我们将学习如何使用 fi ...
- JavaScript根据文件名后缀判断是否图片文件
//JavaScript根据文件名后缀判断是否图片文件 //图片文件的后缀名 var imgExt = new Array(".png",".jpg",&quo ...
- Python批量修改文件名-后缀
LyncLynn用途: 批量修改文件格式,文件名后缀. #Version: V1.0 #Author:lynclynn #Description:Change the filename #Create ...
- 批量修改文件名后缀,例如:html修改成HTML
批量修改文件名后缀,例html修改成HTML 把文件后缀名html全部修改成HTML: 例:aa.html aa.HTML #!/bin/bash for file in `ls`;do mv $fi ...
- Windows系统开启显示文件名后缀
更新记录 2022年4月16日:本文迁移自Panda666原博客,原发布时间:2021年8月26日. 通常Windows系统根据文件名称的后缀来确定文件的类型.经常让朋友出现软件方面的问题,让其修改一 ...
- 【Python】批量修改指定目录下所有文件的文件名/后缀
[删除.txt文件的后缀] import os, shutil #rootdir = input("请输入文件路径(结尾加上/):") #fileList = os.listdir ...
- ASP.NET获取文件名,后缀名
using System.IO; //引入命名空间 string path = "text.aspx"; string pathName = Path.GetFileName(pa ...
- MVC4 路由参数带点 文件名后缀导致错误
错误描述 最近在研究office在线预览,用到mvc4 apicontroller 需要传参是文件名,如test.docx导致错误"指定的目录或文件在 Web 服务器上不存在", ...
随机推荐
- Docker实战-编写Dockerfile
一.编译镜像 1. 编译镜像 Dockerfile类似于Makfile,用户使用docker build就可以编译镜像,使用该命令可以设置编译镜像时使用的CPU数量.内存大小.文件路径等 语法:doc ...
- Android开发(四)——Android中的颜色
Android开发中关于资源文件的存储操作.对于Android资源也是非常重要的,主要包括文本字符串(strings).颜色(colors).数组(arrays).动画(anim).布局(layout ...
- ios 根据scrollview滑动的偏移计算滑动到第几页算法(不同需求不同计算)
第一种: CGFloat pageWidth = self.scrollView.frame.size.width; int page = floor((self.scrollView.content ...
- 如何在wpf实现进度条
using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; u ...
- [转]Oracle SQL函数pivot、unpivot转置函数实现行转列、列转行
原文地址:http://blog.csdn.net/seandba/article/details/72730657 函数PIVOT.UNPIVOT转置函数实现行转列.列转行,效果如下图所示: 1.P ...
- 在 Linux 下用 grep 时高亮显示匹配的部分
用 grep 匹配文件时,显示结果黑压压的一片执行一下这条命令,重新 grep 试试看export GREP_OPTIONS='--color=auto'好看多了,不是吗?你可以把 export GR ...
- 抓包程序可抓一切数据(破微信oauth2限制) 完整教程
1.下载fiddler 官网下载或者 https://www.cr173.com/soft/57378.html 2.按图设置 3.重启软件 4.看下自己的网络IP cmd->ipconfig ...
- php 扩展包链接
https://pecl.php.net/package-stats.php?cid=7
- WebRTC 源码分析(四):VideoCRE 与内存抖动优化
WebRTC 是个宝,初窥这部分代码时就被它的 Capturer 类的设计惊艳到了,仔细品鉴后越发佩服起来,里面简直填了太多坑了,如此宝贝,如不能为我所用,岂非一大憾事!而前三篇的解读,正是为了今天能 ...
- 微信小程序——button, swiper等默认样式更改
微信开发工具里面,无法展示编译后的一些样式,如::before,::after这些伪类.有时候我们需要修改一些组件的默认样式会略感到麻烦,因为不知道是通过哪里控制的. 我就平常遇到的一些修改默认样式, ...