黑马《linux基础编程》学习笔记(从16到20)
十六. find常用参数
[root@VM_0_15_centos home]# tree test
test
|-- son2
| |-- a
| | |-- bye.txt
| | `-- hello.txt
| `-- son
| `-- hello.txt
|-- son3
| `-- hello.txt
`-- target4 directories, 5 files//文件名查找
[root@VM_0_15_centos home]# find test/ -name "bye.txt"
test/son2/a/bye.txt//文件类型查找
[root@VM_0_15_centos home]# find test/ -type d
test/
test/son3
test/son2
test/son2/a
test/son2/son//文件大小查找
[root@VM_0_15_centos home]# find test/ -size +1k
test/
test/son3
test/son2
test/son2/a
test/son2/son//文件创建日期查找
[root@VM_0_15_centos home]# find test/ -ctime -10
test/
test/target
test/son3
test/son3/hello.txt
test/son2
test/son2/a
test/son2/a/bye.txt
test/son2/a/hello.txt
test/son2/son
test/son2/son/hello.txt//文件访问日期查找
[root@VM_0_15_centos home]# find test/ -atime -1//文件修改日期查找
[root@VM_0_15_centos home]# find test/ -mtime -1//搜索n层以下的目录
[root@VM_0_15_centos home]# find test/ -maxdepth 2
test/
test/target
test/son3
test/son3/hello.txt
test/son2
test/son2/a
test/son2/son//搜索n层以上的目录
[root@VM_0_15_centos home]# find test/ -mindepth 1
test/target
test/son3
test/son3/hello.txt
test/son2
test/son2/a
test/son2/a/bye.txt
test/son2/a/hello.txt
test/son2/son
test/son2/son/hello.txt
十七. find高级用法
[root@VM_0_15_centos home]# cd ./test/
[root@VM_0_15_centos test]# find ./ -type d -exec ls -l {} \;
total 8
drwxr-xr-x 4 root root 4096 Oct 27 05:40 son2
drwxr-xr-x 2 root root 4096 Oct 27 05:20 son3
-rw-r--r-- 1 root root 0 Oct 27 05:18 target
total 0
-rw-r--r-- 1 root root 0 Oct 27 05:20 hello.txt
total 8
drwxr-xr-x 2 root root 4096 Oct 27 05:39 a
drwxr-xr-x 2 root root 4096 Oct 27 05:21 son
total 0
-rw-r--r-- 1 root root 0 Oct 27 05:17 bye.txt
-rw-r--r-- 1 root root 0 Oct 27 05:22 hello.txt
total 0
-rw-r--r-- 1 root root 0 Oct 27 05:21 hello.txt//-ok比-exec更安全
[root@VM_0_15_centos test]# find ./ -type d -ok ls -l {} \;
< ls ... ./ > ?
< ls ... ./son3 > ?
< ls ... ./son2 > ?
< ls ... ./son2/a > ?
< ls ... ./son2/son > ?
[root@VM_0_15_centos test]#
[root@VM_0_15_centos test]# find ./ -type d -ok ls -l {} \;
< ls ... ./ > ? y
total 8
drwxr-xr-x 4 root root 4096 Oct 27 05:40 son2
drwxr-xr-x 2 root root 4096 Oct 27 05:20 son3
-rw-r--r-- 1 root root 0 Oct 27 05:18 target
< ls ... ./son3 > ? y
total 0
-rw-r--r-- 1 root root 0 Oct 27 05:20 hello.txt
< ls ... ./son2 > ? y
total 8
drwxr-xr-x 2 root root 4096 Oct 27 05:39 a
drwxr-xr-x 2 root root 4096 Oct 27 05:21 son
< ls ... ./son2/a > ? y
total 0
-rw-r--r-- 1 root root 0 Oct 27 05:17 bye.txt
-rw-r--r-- 1 root root 0 Oct 27 05:22 hello.txt
< ls ... ./son2/son > ? y
total 0
-rw-r--r-- 1 root root 0 Oct 27 05:21 hello.txt//或者,这里用“管道”是更有效率的。
//管道可以简单的理解为一个“缓存区”
[root@VM_0_15_centos test]# find ./ -type d | xargs ls -l
./:
total 8
drwxr-xr-x 4 root root 4096 Oct 27 05:40 son2
drwxr-xr-x 2 root root 4096 Oct 27 05:20 son3
-rw-r--r-- 1 root root 0 Oct 27 05:18 target./son2:
total 8
drwxr-xr-x 2 root root 4096 Oct 27 05:39 a
drwxr-xr-x 2 root root 4096 Oct 27 05:21 son./son2/a:
total 0
-rw-r--r-- 1 root root 0 Oct 27 05:17 bye.txt
-rw-r--r-- 1 root root 0 Oct 27 05:22 hello.txt./son2/son:
total 0
-rw-r--r-- 1 root root 0 Oct 27 05:21 hello.txt./son3:
total 0
-rw-r--r-- 1 root root 0 Oct 27 05:20 hello.txt
十八. grep搜索文件内容
[root@VM_0_15_centos home]# grep -r "answer" ./test/
./test/son2/a/bye.txt:answer
[root@VM_0_15_centos home]# grep -r "hello" ./^C
[root@VM_0_15_centos home]# grep -r "answer" ./test/ ~-n
./test/son2/a/bye.txt:answer
grep: ~-n: No such file or directory
[root@VM_0_15_centos home]# grep -r "answer" ./test/ -n
./test/son2/a/bye.txt:1:answer
十九. tar的压缩和解压缩
[root@VM_0_15_centos home]# tar zcvf test_tar.tar.gz a1.txt a2.txt test
a1.txt
a2.txt
test/
test/target
test/son3/
test/son3/hello.txt
test/son2/
test/son2/a/
test/son2/a/bye.txt
test/son2/a/hello.txt
test/son2/son/
test/son2/son/hello.txt[root@VM_0_15_centos home]# ls
a1.txt a.txt file.c mycal Pointer tom
a2.txt cjz hello.txt myhome.tar.gz test virtualenvs
apple.txt c.txt hello.zip orange.txt TestDjango zf
a.tar.gz date.txt LinkToRoot poem test_tar.tar.gz zsf[root@VM_0_15_centos home]# tar zxvf test_tar.tar.gz -C ./cjz
a1.txt
a2.txt
test/
test/target
test/son3/
test/son3/hello.txt
test/son2/
test/son2/a/
test/son2/a/bye.txt
test/son2/a/hello.txt
test/son2/son/
test/son2/son/hello.txt
[root@VM_0_15_centos home]# ls
a1.txt a.txt file.c mycal Pointer tom
a2.txt cjz hello.txt myhome.tar.gz test virtualenvs
apple.txt c.txt hello.zip orange.txt TestDjango zf
a.tar.gz date.txt LinkToRoot poem test_tar.tar.gz zsf[root@VM_0_15_centos home]# cd cjz
[root@VM_0_15_centos cjz]# ls
a1.txt a2.txt test
[root@VM_0_15_centos cjz]#
二十. rar的压缩和解压缩
//首先,rar是没有安装的,我们接下来先安装一下
[root@VM_0_15_centos home]# rar
-bash: rar: command not found[root@VM_0_15_centos home]# wget http://www.rarsoft.com/rar/rarlinux-x64-5.4.0.tar.gz
--2018-10-28 19:20:34-- http://www.rarsoft.com/rar/rarlinux-x64-5.4.0.tar.gz
Resolving www.rarsoft.com (www.rarsoft.com)... 5.135.104.108
Connecting to www.rarsoft.com (www.rarsoft.com)|5.135.104.108|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://www.rarlab.com/rar/rarlinux-x64-5.4.0.tar.gz [following]
--2018-10-28 19:20:38-- http://www.rarlab.com/rar/rarlinux-x64-5.4.0.tar.gz
Resolving www.rarlab.com (www.rarlab.com)... 5.135.104.98
Connecting to www.rarlab.com (www.rarlab.com)|5.135.104.98|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://www.rarlab.com/rar/rarlinux-x64-5.4.0.tar.gz [following]
--2018-10-28 19:20:40-- https://www.rarlab.com/rar/rarlinux-x64-5.4.0.tar.gz
Connecting to www.rarlab.com (www.rarlab.com)|5.135.104.98|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 531782 (519K) [application/x-gzip]
Saving to: ‘rarlinux-x64-5.4.0.tar.gz’100%[======================================>] 531,782 10.7KB/s in 47s2018-10-28 19:21:29 (11.0 KB/s) - ‘rarlinux-x64-5.4.0.tar.gz’ saved [531782/531782][root@VM_0_15_centos home]# ls
a1.txt cjz hello.zip poem test_tar.tar.gz
a2.txt c.txt LinkToRoot Pointer tom
apple.txt date.txt mycal rarlinux-x64-5.4.0.tar.gz virtualenvs
a.tar.gz file.c myhome.tar.gz test zf
a.txt hello.txt orange.txt TestDjango zsf//用tar解压rar的安装包
[root@VM_0_15_centos home]# tar zxvf rarlinux-x64-5.4.0.tar.gz
rar/
rar/rar.txt
rar/license.txt
rar/readme.txt
rar/order.htm
rar/whatsnew.txt
rar/acknow.txt
rar/rar
rar/unrar
rar/makefile
rar/default.sfx
rar/rarfiles.lst[root@VM_0_15_centos home]# ls
a1.txt c.txt mycal rarlinux-x64-5.4.0.tar.gz zf
a2.txt date.txt myhome.tar.gz test zsf
apple.txt file.c orange.txt TestDjango
a.tar.gz hello.txt poem test_tar.tar.gz
a.txt hello.zip Pointer tom
cjz LinkToRoot rar virtualenvs[root@VM_0_15_centos home]# cd rar[root@VM_0_15_centos rar]# ls
acknow.txt license.txt order.htm rarfiles.lst readme.txt whatsnew.txt
default.sfx makefile rar rar.txt unrar[root@VM_0_15_centos rar]# make
mkdir -p /usr/local/bin
mkdir -p /usr/local/lib
cp rar unrar /usr/local/bin
cp rarfiles.lst /etc
cp default.sfx /usr/local/lib//rar安装完成
[root@VM_0_15_centos rar]# cd ..
[root@VM_0_15_centos home]# ls
a1.txt c.txt mycal rarlinux-x64-5.4.0.tar.gz zf
a2.txt date.txt myhome.tar.gz test zsf
apple.txt file.c orange.txt TestDjango
a.tar.gz hello.txt poem test_tar.tar.gz
a.txt hello.zip Pointer tom
cjz LinkToRoot rar virtualenvs//用rar压缩一个包
[root@VM_0_15_centos home]# rar a test_rar a1.txt s2.txt cjzRAR 5.40 Copyright (c) 1993-2016 Alexander Roshal 15 Aug 2016
Trial version Type RAR -? for helpEvaluation copy. Please register.Cannot open s2.txt
No such file or directory
Creating archive test_rar.rarAdding a1.txt OK
Adding cjz/.bash_history OK
Adding cjz/.cache/abrt/lastnotification OK
Adding cjz/.bash_profile OK
Adding cjz/a2.txt OK
Adding cjz/test/target OK
Adding cjz/test/son3/hello.txt OK
Adding cjz/test/son2/a/bye.txt OK
Adding cjz/test/son2/a/hello.txt OK
Adding cjz/test/son2/son/hello.txt OK
Adding cjz/.bashrc OK
Adding cjz/a1.txt OK
Adding cjz/.bash_logout OK
Adding cjz/test/son2/a OK
Adding cjz/test/son2/son OK
Adding cjz/.config/abrt OK
Adding cjz/.cache/abrt OK
Adding cjz/test/son3 OK
Adding cjz/test/son2 OK
Adding cjz/.config OK
Adding cjz/.cache OK
Adding cjz/test OK
Adding cjz 1%
Done[root@VM_0_15_centos home]# ls
a1.txt c.txt mycal rarlinux-x64-5.4.0.tar.gz virtualenvs
a2.txt date.txt myhome.tar.gz test zf
apple.txt file.c orange.txt TestDjango zsf
a.tar.gz hello.txt poem test_rar.rar
a.txt hello.zip Pointer test_tar.tar.gz
cjz LinkToRoot rar tom//现在来解压它
[root@VM_0_15_centos home]# ls
] cjz LinkToRoot rar tom
a1.txt c.txt mycal rarlinux-x64-5.4.0.tar.gz virtualenvs
a2.txt date.txt myhome.tar.gz test zf
apple.txt file.c orange.txt TestDjango zsf
a.tar.gz hello.txt poem test_rar.rar
a.txt hello.zip Pointer test_tar.tar.gz
[root@VM_0_15_centos home]# rar x test_rar.rarRAR 5.40 Copyright (c) 1993-2016 Alexander Roshal 15 Aug 2016
Trial version Type RAR -? for helpExtracting from test_rar.rarWould you like to replace the existing file a1.txt0 bytes, modified on 2018-09-02 03:07
with a new one0 bytes, modified on 2018-09-02 03:07[Y]es, [N]o, [A]ll, n[E]ver, [R]ename, [Q]uit AExtracting a1.txt OK
Extracting cjz/.bash_history OK
Extracting cjz/.cache/abrt/lastnotification OK
Extracting cjz/.bash_profile OK
Extracting cjz/a2.txt OK
Extracting cjz/test/target OK
Extracting cjz/test/son3/hello.txt OK
Extracting cjz/test/son2/a/bye.txt OK
Extracting cjz/test/son2/a/hello.txt OK
Extracting cjz/test/son2/son/hello.txt OK
Extracting cjz/.bashrc OK
Extracting cjz/a1.txt OK
Extracting cjz/.bash_logout OK
All OK
[root@VM_0_15_centos home]#
黑马《linux基础编程》学习笔记(从16到20)相关推荐
- 大数据第二阶段Python基础编程学习笔记(待完善)
大数据第二阶段Python基础编程学习笔记(待完善) 第一章 Python基础语法 3.8 1-1Python概述 python基础部分: ●Python基础语法: 标识符,关键字,变量,判断循环.. ...
- 《Linux Shell编程学习笔记之一》
<Linux Shell编程学习笔记之一> 前言 由于自己一直在Windows上面编程,用linux用的比较少,学习linux还是本科大二学的一点点知识.因此自己就准备花点时间来熟悉下li ...
- Linux Shell编程学习笔记(4)
Linux Shell编程学习笔记(2015-7-20) 分类:linux shell 今天学习了Linux Shell中的控制结构.其实大多数语言的控制结构这一块都是基本类似的,有了C语言的基础 ...
- linux磁盘符变化autofs,Linux基础教程学习笔记之Autofs自动挂载
Linux基础教程学习笔记之Autofs自动挂载 Autofs自动挂载: yum -y install autofs vim /etc/auto.master 在文件中添加下面行 /home/gue ...
- 网络存储 linux 访问,Linux基础教程学习笔记28——使用Samba访问网络存储
Linux基础教程学习笔记28--使用Samba访问网络存储 SMB用于Windows和类Linux系统直接的文件共享 安装samba client包: [root@linuxidc~]# yum i ...
- linux基础命令学习笔记(二)
linux基础命令学习笔记(二) 1.kill :终止进程 kill pid (唯一标示一个进程) kill -9 强制终止 kill -15 命令未结束不能终止 # ps aux 查看所有进程 ...
- [Linux网络编程学习笔记]索引
一.Linux基本知识 [学习笔记]Linux平台的文件I/O操作 [学习笔记]Linux平台的文件,目录及操作 [Linux学习笔记]标准输入输出 [Linux学习笔记]进程概念及控制 [Linux ...
- 编程开发:Linux网络编程学习笔记
非常全面.通俗易懂.值得借鉴的Linux网络编程学习笔记.关键字:linux linux编程 网络编程 linux网络编程 下载地址:点我下载 特别说明:本资源收集于网络,版权归原作者及版权商所有,仅 ...
- Linux Shell编程学习笔记(2)
Linux Shell编程学习笔记(2015-7-12) 分类:linux shell Shell变量 一:关于Shell变量 Shell是一种弱类型的语言,变量存储的一切值都是字符串.Shell ...
- Linux Shell编程学习笔记(3)
Linux Shell编程学习笔记(2015-7-19) 分类:linux shell 一:位置参数和特殊变量 什么是位置参数? 位置参数也叫位置变量,是运行shell脚本程序时,命令行she ...
最新文章
- C++: 不可拷贝(noncopyable)类
- 2020-12-3(详解虚拟地址如何转化为物理地址)
- DirectShow学习
- 学习TensorFlow、PyTorch、机器学习、深度学习和数据结构五件套!附下载链接!...
- tf.slice解析
- [OS] 远程启动计划任务时以管理员身份运行
- PWM级联方案。UART接口的单总线控制多个PWM输出。数字舵机,舵机级联方案
- 几种深度学习框架的使用和对比
- java视图扩展_java – 可扩展列表视图 – 子项,不同的布局
- [转载]数字全息与计算全息
- Android 7 soter,安卓首发!OPPO Find X全面支持微信人脸支付功能
- kettle同步数据 (SAP hana到 Mysql)
- AcWing 1183电力(Tarjan求割点)
- Maven与Eclipse的整合和简单的Maven项目(二)
- linux 批量监控软件,Linux/Unix/Windows批量管理监控服务器软件
- 2020金三银四——在家也能躺拿大厂offer
- 4年前端狗,面试被虐,如何翻身?
- windows 时间同步工具软件
- Numpy piecewise报错
- matlab取色工具getpts
热门文章
- iOS 几种常用的 crash log 崩溃信息调试方法. (转载)
- 查看twitter浏览记录_您可以看到谁查看了您的Twitter个人资料吗?
- 夜天之书 #78 共建的神话
- 【古希腊罗马神话】期末结课论文
- 人口红利消失,电销要怎么做才能立足市场?
- 7.Unity2D 横版 未受伤害时,血条缓慢变透明+伤害数值显示(浮动,大小,颜色)+协程的应用
- ImageNet预训练参数和随机初始化参数训练效果对比
- 前沿 | 国际可视化盛会PacificVis2017的十个精彩案例
- 嵌入式Linux自学笔记(二)——文件IO
- Linux 运维常见英文单词