find和壓縮

find
格式:find / [參數] -exec 命令
搜索名稱:find / -name ".txt" -----加引號
搜索用戶:find / -user wang
搜索uid/gid:find / -uid/gid
搜索類型:find / -type
搜索深度:find / --maxdepth 1 --mindepth 1
搜索空目錄:find / -empty
搜索空文件:find / -type f -empty
或者關係:find / -type f -o -empty
否關係:-not
而且關係:-a(優先級高)
取反查找:find / ! ( -type f -a -empty )
排除目錄查找:find /etc -path '/etc/security' -a -prune(去除某分支) -o -name "










.conf"
排除/etc/security目錄查找或者文件名稱爲.conf的文件
多重排除:find / ( -path "/sys" -o -path "/proc" ) -a -prune -o -name "
.conf"
大小查找:-size 減一原則,-size 6k 查找範圍(6k --6k-1),-size 600 查找範圍(600 -599)
統計全部查找的文件內容行數:find /etc -name "*.conf" |xargs cat | wc -l




數據庫

以天爲單位查找
    -atime   【+|-】#  (天數是加一的)
    -mtime
    -ctime

以分鐘爲單位
    -amin    
    -mmin
    -cmin

按照權限查找:
    -perm  /600 (u權限有讀或者寫權限,go無權限)
    -perm  -600 (u權限有讀並且有寫權限,go無權限)

對於查找符合條件的內容再操做:
    find  /root  -name "*.txt" -delete  (刪除)
    find /root -name "*.txt" -ok mv {} /tmp \;  (移動文件並詢問)
     find /root -name "*.txt" -exec mv {} /tmp \;(強制移動不詢問)

xargs,將標準輸入的內容做爲參數
    touch {1..10}.txt |ls *.txt|xargs -n1 rm -rf
    並行下載視頻:seq 10 |xargs -i -P3(開啓三條並行下載通道)   you-get https://*****p={}

locate
查詢存在內存庫的文件,須要配合updatedb,更新內存庫
ide

tar
gz壓縮:tar czvf test.tar.gz /etc
bz壓縮:tar cjvf test.tar.bz /etc
查看壓縮文件:tar tvf test.tar.gz/bz
解壓縮:tar xzvf test.tar.gz
tar xjvf test.tar.bz
壓縮時排除某文件:--exclude





ui

gzip
-k 保存源文件並壓縮
-d 解壓縮或者gunzip
-1 壓縮速度最快
-9 壓縮比例最大
cat m |gzip >m.gz(可用於數據庫備份的壓縮歸檔)




加密

bzip2
壓縮比例更大,利於下載
code

-k 保存源文件並壓縮

-d 解壓縮或者bunzip2

-1 壓縮速度快

-9 壓縮比例最大

xz-----unxz
(編寫自動解壓縮腳本)
視頻

zip
-r 對目錄壓縮
ip

-P 加密壓縮

unzip
-P 解壓加密文件
內存

eg:zip -r -P123456 T.zip T
unzip -P123456 /root/T.zip
get

gzip-bzip2-xz僅對文件壓縮
zip可對目錄壓縮
it

split
分割文件一個或者多個
-b 指定分割大小,文件名默認時加字母
-d 指定以數字命名分割文件


cpio解壓和壓縮,特殊格式

相關文章
相關標籤/搜索