Category Archives: 電腦相關

find 的用法

Syntax: find pathname-list expression

-name filename
-perm octnum
-print
-type t/f/c/b t:目錄 f:檔案 c:字元特殊檔 b:區域特殊檔
-exec rm -rf “{}” \;
把pathname-list裡所有file通通砍掉
-size n
+n (大於n)
-n (小於n)

-mtime n (幾天內被修改過)

example:
find ~ -name “*.c” -print
find / -size 0 -exec rm “{}” \;
find / -perm 4755 -print
find ~ -type d -print

實例:
找到大於10mb的檔案並刪除之
find . -type f -size +10000 -exec rm “{}” \;

找到所有包含 blahblah 字串的檔案
find . -type f -exec grep -l blahblah “{}” \;

列出所在目錄下所有檔案
find . -type f -print

Enable Soft-Updates

tunefs -n enable + 掛載區

怕忘記所以寫起來:~

利用 apt-file 來搜尋檔案/套件名稱

最近因為某些需求,開始回頭用 Ubuntu/Debian

最近有人問我,有沒有辦法找出某個已安裝的套件名稱,或者找出某個檔案屬於哪個套件

前者可以用 dpkg 或 dlocate -S 來達到目的

不過後者我當時回答不上來

找了一下資料,apt-file 似乎是個不錯的 tool

安裝 apt-file
sudo apt-get install apt-file
更新 apt-file 的資料
sudo apt-file update
利用 apt-file 找出套件
sudo apt-file search gcc-3.4

還有許多有趣的玩法及組合,就慢慢參考 man manual 吧:p