1 時間日期指令
1.1 date
date 顯示當前時間
date +%Y 顯示當前年份
date +%m 顯示當前月份
date +%d 顯示今天
date "+%Y -%m-%d %H:%M:%S" 顯示年月日時分秒
date -s "2023-03-03 03:03:03" 設定時間為2023-03-03 03:03:03
[root@HSP01 ~]# date 2023年 03月 10日 星期五 09:15:33 CST [root@HSP01 ~]# date +%m 03 [root@HSP01 ~]# date "+%Y -%m-%d %H:%M:%S" 2023 -03-10 09:16:22
1.2 cal
顯示日歷
cal 顯示當月日歷
cal 年份 顯示某一年日歷
[root@HSP01 ~]# cal 三月 2023 日 一 二 三 四 五 六 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
2 搜索查找指令
2.1 find
從指定目錄向下遍歷所有目錄查找指定檔案,
find 指定目錄 -name 指定檔案 從指定目錄向下遍歷所有目錄按名稱查找指定檔案
find 指定目錄 -user 指定用戶名 查找指定目錄下指定用戶的所有檔案
find 指定目錄 -size 檔案大小 查找指定目錄下符合大小所有檔案(+n 大于n -n 小于n n 等于 單位:k,M或G)
[root@HSP01 ~]# find /home -name test /home/test [root@HSP01 ~]# find /home -user sora /home/sora /home/sora/.bash_logout /home/sora/.config /home/sora/.config/abrt /home/sora/.bash_history /home/sora/.mozilla /home/sora/.mozilla/plugins /home/sora/.mozilla/extensions /home/sora/.bashrc /home/sora/.bash_profile /home/sora/.cache /home/sora/.cache/abrt /home/sora/.cache/abrt/lastnotification [root@HSP01 ~]# find /home -size +5M /home/laffy/.cache/mozilla/firefox/ri8vp6vr.default-default/startupCache/scriptCache.bin
2.2 locate
locate可以實作快速定位檔案路徑,利用建立的路徑系統可以在無需遍歷整個系統的情況下快速查找檔案,
locate 檔案名
注:使用前先利用指令updatedb更新路徑,
[root@HSP01 ~]# updatedb [root@HSP01 ~]# locate Sora.PNG /home/sora/Sora.PNG /opt/tmp/home/sora/Sora.PNG
3 grep&|
grep :過濾查找,
管道符“|”:表示將前一個命令的處理結果輸出傳遞給后面的命令處理,
grep -n 查找內容 檔案 在檔案中查找相關內容且顯示行號
grep -i 查找內容 檔案 在檔案中查找相關內容且忽略大小寫(無論大小寫都會被查找出來)
[root@HSP01 test]# grep -n life /home/test/app.txt 4:With the quickening pace of urban life and ever-increasing pressure, people in growing numbers are suffering from either the physical or mental problems. [root@HSP01 test]# grep -i it /home/test/app.txt It is a wonderful day! wherever you are,it is no doubt that i will meet you. With the quickening pace of urban life and ever-increasing pressure, people in growing numbers are suffering from either the physical or mental problems. As the job market is getting gloomy and competition is becoming fierce, it is increasingly difficult for college undergraduates to find a decent job.
4 壓縮解壓指令
4.1 gzip&gunzip
gzip 壓縮檔案,不能用于檔案夾
gunzip 解壓檔案,不能用于檔案夾
4.2 zip&unzip
壓碩訓解壓檔案
zip 檔案 壓縮檔案
unzip 檔案 解壓檔案或檔案夾
zip -r 壓縮后檔案名 檔案夾 壓縮檔案夾
unzip -d 路徑 檔案 解壓檔案到指定路徑
[root@HSP01 home]# ls jack laffy murasame myroot sora test [root@HSP01 home]# zip -r mytest.zip test adding: test/ (stored 0%) adding: test/A/ (stored 0%) adding: test/A/hello.cpp (deflated 48%) adding: test/A/B (deflated 26%) adding: test/A/app.txt (deflated 26%) adding: test/app.txt (deflated 38%) [root@HSP01 home]# ls jack laffy murasame myroot mytest.zip sora test [root@HSP01 home]# unzip -d /home/sora/ /home/mytest.zip Archive: /home/mytest.zip creating: /home/sora/test/ creating: /home/sora/test/A/ inflating: /home/sora/test/A/hello.cpp inflating: /home/sora/test/A/B inflating: /home/sora/test/A/app.txt inflating: /home/sora/test/app.txt [root@HSP01 home]# ls sora Sora.PNG test
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/546397.html
標籤:其他
