小白学Linux命令

(在指定目录)查找文件,并输出结果到指定文件
find /var/opt/ -name "*testFile*" >> /home/testUser/Desktop/findtestFileresult.txt
find /var/opt/ -name "*20191218.1215*" >> /home/testUser/Desktop/find20191218d1215result.txt
find /home -name "*Findresult*" >> /home/testUser/Desktop/findTxtresult.txt

【cd /】 返回上一级目录
【ls】    列出当前路径文件夹
【pwd】    显示当前路径
【find . -name 'test'】    根据名称查询名为test的文件夹



3种根据日期压缩文件的方法

zip -rjgu /home/testUser/Documents/test/20190822/testFile.zip /var/opt/testFile/C20190822*

zip -rjgu -t 07082019 /home/testUser/Documents/test/20190708/AM/testFile.zip /var/opt/tmpFileStore/testFile

zip -rjgu -t 02292020 -tt 03012020 /home/testUser/2.zip /var/opt/
zip -rjgu -t 02292020 -tt 03012020 /home/testUser/3.zip /var/opt/

mkdir [directory]

To delete directories that are not empty, use the -r (recursive) option. To be clear, this removes the directories and all files and sub-directories contained within them.

rm -r directory1 directory2 directory3

If a directory or a file is write-protected, you will be prompted to confirm the deletion. To delete directories that are not empty and to suppress these prompts, use the -r (recursive) and -f (force) options together.

rm -rf directory

rm /tmp/foo/*

To remove a directory that contains other files or sub-directories, use the following rm command command. In the example, I am going to empty directory named “docs” using the rm -rf command as follows:
rm -rf /tmp/docs/*
Get verbose outputs:
rm -rfv /tmp/docs/*

find . -name "*.java"
find foo bar -name "*.java"


find 20200908 20200909 -name "*.zip" -type f -exec unzip -jd "/var/opt/temp/" "{}" ".0000*K001*" ".0000*K002*" ".0000*K004*" "*.0000*K005*" \;

unzip -n "*zip" "*[PprR][0-9AadD][0-9FfRr]"

find 20200908 20200909 -name "*.2000*.zip" -type f -exec unzip -jd "/var/temp/" "{}" "*[KI]00[0-9]*" \;

find 20200908 20200909 -name "*1945*.zip" -type f -exec unzip -jd "/var/temp/" "{}" "*KI00[0-2][0-9]*" \;

find 20200908 20200909 -name "*0000*.zip" -type f -exec unzip -jd "/var/temp/" "{}" "*.0000*KI(2227|9109|2460|2204|2238|2211|2209|2203|2210|2201|2215|2213|2202|0294|2208|2206|2205|2207|0293|0326|0296|0867|0292|0746)*" \;
posted @ 2020-09-12 13:21  柠檬茶多放糖  阅读(102)  评论(0编辑  收藏  举报