首页 > 其他分享 >四剑客第三关

四剑客第三关

时间:2024-03-14 18:33:34浏览次数:27  
标签:abc tar 剑客 master 第三关 txt root find

四剑客第三关

1 find使用方法:
根据文件大小查找 命令:
根据文件权限查找数据 :

find /etc/passwd -type f -size +10M


find /etc/passwd -perm 755



[root@master ~]# find /etc/passwd -type f -size +10M
[root@master ~]# find /etc/passwd -perm 755


2 把 abc压缩成格式如 2020-09-29.abc.tar.gz

tar -zcf "$(date +%Y-%m-%d).abc.tar.gz" abc




[root@master ~]# cat abc
dshjfgsd
sdkfhksdf
sdkfgsdf
flksehfhes
sakhjfasjghdfas
fjnksdfsdjf



sdfjkhsdjfse
sajkefhjsegf

wenrjeshfukse
wejnrkhefghwe
rasejghfujiwebf
'fsebjfhse
ejkrgsefhe
sekfbegfe
askefseuifbwejfsekjtg
wjkerusegufhbse
sejnkrghsehjfge
tnwejfhwejfbwe
asnjefghesjkf
se'e,k



ejkrgseuiuhe


enrjsehfwe

awejkfjiwehf


sejkhrsehfw
'arnweh


serheuishfuihwe




[root@master ~]# tar -zcf "$(date +%Y-%m-%d).abc.tar.gz" abc
[root@master ~]# ls
10.txt  14.txt  18.txt                 20.txt  3.txt  7.txt  anaconda-ks.cfg        nwq1.6.sh
11.txt  15.txt  19.txt                 21.txt  4.txt  8.txt  CentOS6-Base-163.repo  profile
12.txt  16.txt  1.txt                  22.txt  5.txt  9.txt  hosts
13.txt  17.txt  2024-03-14.abc.tar.gz  2.txt   6.txt  abc    motd


3 解压如上文件

tar -xzf "2020=09-29.abc.tar.gz"

 tar -xzf "2024-03-14.abc.tar.gz"  -C /test  解压到目录


[root@master ~]# tar -xzf "2024-03-14.abc.tar.gz"  -C /test
[root@master ~]# cd /test
[root@master test]# ls
abc
[root@master test]# cat abc
dshjfgsd
sdkfhksdf
sdkfgsdf
flksehfhes
sakhjfasjghdfas
fjnksdfsdjf



sdfjkhsdjfse
sajkefhjsegf

wenrjeshfukse
wejnrkhefghwe
rasejghfujiwebf
'fsebjfhse
ejkrgsefhe
sekfbegfe
askefseuifbwejfsekjtg
wjkerusegufhbse
sejnkrghsehjfge
tnwejfhwejfbwe
asnjefghesjkf
se'e,k



ejkrgseuiuhe


enrjsehfwe

awejkfjiwehf


sejkhrsehfw
'arnweh


serheuishfuihwe






4 美元符号:$ 表达什么:
!作用:
| 作用:
xargs作用:

$ 引用变量或命令替换
!   执行历史记录或逻辑非操作  通常与[]结合使用
|  前一个命令的输出作为后一个命令的输入

5 查找指定数据信息进行复制 查找出.txt文件,批量复制到/tmp目录

find . -name "*.txt" |xargs cp -t /tmp
或者
find . -name "*.txt" -exec cp {} /tmp \;





[root@master ~]# touch {1..22}.txt
[root@master ~]# ls
10.txt  13.txt  16.txt  19.txt  21.txt  3.txt  6.txt  9.txt                  hosts      profile
11.txt  14.txt  17.txt  1.txt   22.txt  4.txt  7.txt  anaconda-ks.cfg        motd
12.txt  15.txt  18.txt  20.txt  2.txt   5.txt  8.txt  CentOS6-Base-163.repo  nwq1.6.sh
[root@master ~]# find . -name "*.txt" -exec cp {} /tmp \;
[root@master ~]# ls
10.txt  13.txt  16.txt  19.txt  21.txt  3.txt  6.txt  9.txt                  hosts      profile
11.txt  14.txt  17.txt  1.txt   22.txt  4.txt  7.txt  anaconda-ks.cfg        motd
12.txt  15.txt  18.txt  20.txt  2.txt   5.txt  8.txt  CentOS6-Base-163.repo  nwq1.6.sh
[root@master ~]# cd /tmp
[root@master tmp]# ls
10.txt  14.txt  18.txt  21.txt  4.txt  8.txt       yum_save_tx.2024-03-09.20-43.MjeG_P.yumtx
11.txt  15.txt  19.txt  22.txt  5.txt  9.txt
12.txt  16.txt  1.txt   2.txt   6.txt  test01.txt
13.txt  17.txt  20.txt  3.txt   7.txt  test.txt

6 查找指定数据信息进行移动 查找出*.txt文件,批量移动到/tmp目录

find . -name "*.txt" -exec mv {} /tmp \;




[root@master ~]# touch {1..20}.txt
[root@master ~]# ls
10.txt  13.txt  16.txt  19.txt  2.txt  5.txt  8.txt            CentOS6-Base-163.repo  nwq1.6.sh   test.txt
11.txt  14.txt  17.txt  1.txt   3.txt  6.txt  9.txt            hosts                  profile
12.txt  15.txt  18.txt  20.txt  4.txt  7.txt  anaconda-ks.cfg  motd                   test01.txt
[root@master ~]# find . -name "*.txt"
./1.txt
./test.txt
./test01.txt
./2.txt
./3.txt
./4.txt
./5.txt
./6.txt
./7.txt
./8.txt
./9.txt
./10.txt
./11.txt
./12.txt
./13.txt
./14.txt
./15.txt
./16.txt
./17.txt
./18.txt
./19.txt
./20.txt
[root@master ~]# find . -name "*.txt" -exec mv {} /tmp \;

[root@master ~]# cd /tmp
[root@master tmp]# ls
10.txt  13.txt  16.txt  19.txt  2.txt  5.txt  8.txt       test.txt
11.txt  14.txt  17.txt  1.txt   3.txt  6.txt  9.txt       yum_save_tx.2024-03-09.20-43.MjeG_P.yumtx
12.txt  15.txt  18.txt  20.txt  4.txt  7.txt  test01.txt

7 将以abc开头的行找出来?

语法  grep  "^abc"  文件名

grep "^abc" /etc/passwd



[root@master ~]# cat test01.txt 
sdjfgs
sdjkhfjksdhf


sdfjksdkfhshd
sdjfhjsgf
sdkfhksduise
jkshfhsdb
ashdfsdf
linux fsdhfsdfjsfhshdfslinux
sdjfjsdfs
askjdfasugfugsef
sensfhasgf
asekfsehf
eksheshb
abcehiehkheke
ejkrsehfuies
abcehiiegbwejthiehi


efjhehew

rjkthrkhgwe
eklrhteh

etwehut

ethkeht

ejkfekhre
ehrkefie
nrekwhwet
ekhke



ektheh



[root@master ~]# grep '^abc' test01.txt 
abcehiehkheke
abcehiiegbwejthiehi



8 将以linux结尾的行找出来?

grep 'linux$' 文件名


[root@master ~]# cat test01.txt 
sdjfgs
sdjkhfjksdhf


sdfjksdkfhshd
sdjfhjsgf
sdkfhksduise
jkshfhsdb
ashdfsdf
linux fsdhfsdfjsfhshdfslinux
sdjfjsdfs
askjdfasugfugsef
sensfhasgf
asekfsehf
eksheshb
abcehiehkheke
ejkrsehfuies
abcehiiegbwejthiehi


efjhehew

rjkthrkhgwe
eklrhteh

etwehut

ethkeht

ejkfekhre
ehrkefie
nrekwhwet
ekhke



ektheh



[root@master ~]# grep 'linux' test01.txt 
linux fsdhfsdfjsfhshdfslinux


9 将全部内容显示,但不要显示空行

grep -v '^$' 文件名




[root@master ~]# cat test01.txt 
sdjfgs
sdjkhfjksdhf


sdfjksdkfhshd
sdjfhjsgf
sdkfhksduise
jkshfhsdb
ashdfsdf
linux fsdhfsdfjsfhshdfslinux
sdjfjsdfs
askjdfasugfugsef
sensfhasgf
asekfsehf
eksheshb
abcehiehkheke
ejkrsehfuies
abcehiiegbwejthiehi


efjhehew

rjkthrkhgwe
eklrhteh

etwehut

ethkeht

ejkfekhre
ehrkefie
nrekwhwet
ekhke



ektheh



[root@master ~]# grep -v '^$' test01.txt 
sdjfgs
sdjkhfjksdhf
sdfjksdkfhshd
sdjfhjsgf
sdkfhksduise
jkshfhsdb
ashdfsdf
linux fsdhfsdfjsfhshdfslinux
sdjfjsdfs
askjdfasugfugsef
sensfhasgf
asekfsehf
eksheshb
abcehiehkheke
ejkrsehfuies
abcehiiegbwejthiehi
efjhehew
rjkthrkhgwe
eklrhteh
etwehut
ethkeht
ejkfekhre
ehrkefie
nrekwhwet
ekhke
ektheh

10 利用linux什么命令真正统计目录的大小?

du -sh /etc/passwd



[root@master ~]# du -sh /etc/passwd
8.0K	/etc/passwd


标签:abc,tar,剑客,master,第三关,txt,root,find
From: https://www.cnblogs.com/nwq1101/p/18073665

相关文章

  • 四剑客第一关
    四剑客第一关1.修改当前时间为明天日期date-s"2024-03-14"date-s"$(date-dtomorrow+%Y-%m-%d)"修改date-s"$(date-dtomorrow+%Y-%m-%d)"[root@master~]#date-s"2024-03-13"WedMar1300:00:00CST2024[root@master~]#d......
  • Linux文本三剑客超详细教程---grep、sed、awk
    Linux文本三剑客超详细教程---grep、sed、awk羽林君 2023-10-1223:51 广东文章来源:https://www.cnblogs.com/along21/p/10366886.html awk、grep、sed是linux操作文本的三大利器,合称文本三剑客,也是必须掌握的linux命令之一。三者的功能都是处理文本,但侧重点各不相......
  • Linux文本处理三剑客---grep
    1.什么是grep和egrep示例grep[options]pattern[file...]其中,pattern表示要搜索的模式,可以是简单的文本字符串,也可以是正则表达式。file指定要在其中进行搜索的文件,如果省略file,则默认从标准输入中读取数据。egrep其实就是grep的一个变种,它支持更多的正则表达式语法。egre......
  • 轻松掌握 Linux 文本处理三剑客:grep、awk 和 sed 实战演练
     Shell脚本语言编程有哪些优势呢?Shell脚本语言的优势在于能够以最轻量级最快捷的速度处理Linux操作系统偏底层的业务。比如软件的自动化安装、更新版本,监控报警,日志分析等。虽然其他高级编程语言如PHP、Python、Ruby等语言也能做到,但是效率和开发成本上会大打折扣,所谓“......
  • 三剑客—sed
    关于linux三剑客grep,过滤关键字信息数据。主要是用于查文本内的数据sed,对文本数据进行编辑,修改原文件内容awk,对文件数据过滤,提取,并且能实现,格式化输出awk对文件数据处理后,还能更美观的展示数据sed是什么sed软件本身sed提供的加工的命令给sed提供的源数据sed语法......
  • 网页 三剑客
    网页三剑客,是一套强大的网页编辑工具,最初是由美国的Macromedia公司开发出来的。由Dreamweaver,Fireworks,Flash三个软件组成,俗称网页三剑客。Dreamweaver是一个“所见即所得”的可视化网站开发工具,主要用于动态网页和静态网页的开发;Fireworks主要是用于对网页上常用的jpg、gif的制......
  • day29_三剑客sed
    关于学正则单个正则字符还认识组合到一起就晕了,怎么办?本质还是对单个字符没理解.认识*认识.*组合到就一起就蒙了,为什么?还是没想明白.的意义,*的意义正则表达式,从左向右,逐步理解单个字符的意义怎么做?1.思维脑图写没写?2.每一个正则表达式的符号,自己有没有动手......
  • day30-三剑客awk
    awk是什么再谈三剑客grep,擅长单纯的查找或匹配文本内容sed,更适合编辑、处理匹配到的文本内容awk,更适合格式化文本内容,对文本进行复杂处理后、更友好的显示三个命令称之为Linux的三剑客awk学完后的能力以下部分内容需要结合shell编程对文本行数据提取数据字段模式、动......
  • 第三关-Less-3
    第三关-Less-3:GET-Errorbased-Singlequoteswithtwiststring(基于错误的GET单引号变形字符型注入):判断注入点:当我们在输入?id=1'的时候看到页面报错信息。可推断sql语句是单引号字符型且有括号,所以我们需要闭合单引号且也要考虑括号。这时我们来查看源码的关键部分......
  • 第十四天:文件处理三剑客之awk
    一、awk工作原理和基本用法  二、动作print 三、awk变量1、内置变量OFS:指定输出的分隔符 NF:字段变量NR:记录的编号FNR:各文件分别计数,记录的编号FILENAME:当前文件名ARGC:命令行参数的个数ARGV:数组,保存的是命令行所给定的各参数,每一个参数:ARGV[0]2......