grep
grep targetWord * ## find target word on the same directory
grep 'targetWords More ' * ## find target word on the same directory
locate
e.g. locate passwd
locate 尋找的資料是由『已建立的資料庫 /var/lib/mlocate/』update the dataFile is depend on difference liux, e.g. redhat, cenos
step
1 updatedb:根據 /etc/updatedb.conf 的設定去搜尋系統硬碟內的檔名,並更新 /var/lib/mlocate
2 locate:依據 /var/lib/mlocate 內的資料庫記載,找出使用者輸入的關鍵字檔名。
find
find 尋找檔案的指令,會將欲尋找的檔案找出來,例如下面的例子:
# find / -name bin 上面的意思為:在 / 目錄(根目錄)下尋找檔名(-name)為 bin 的檔案,要注意的是,因為 Linux 的檔案很多,如果你的電腦比較舊,可能會找很久... 語法: find 路徑 -name 檔名
whereis 相對於 find ,你也可以使用 whereis 這個指令來下達找尋的檔案,whereis 利用曾經找過的系統資訊內的資料去找檔案,所以速度會很快,不過,如果 whereis 找不到的話,並不代表該檔案真的不存在!這個要小心! [root@tsai /root]# whereis bin bin: /usr/bin
- mv oldname.txt newname.txt ; mv 20061118 /backup/backup/20061118
- rm delfilename.* -f ;rm directoryName -fR && delete file and directory , remark I don't know the recover.
- find . -type f -name "*.bak" -exec rm -i {} \;find . -name "*.fetchmailrc" -print | xargs sed -i 's/Oldvalue/NewValue/g' ## find and replace
- find . -maxdepth 1 -type f -mtime +30 | rsync -av --remove-source-files --files-from=- . archive/ ## remove
- find . -size +300M -print | xargs ls -l
- find -type d print0 | xargs -0 chmod 777 (change only directry)
- find -type f -mtime +100 | xargs ls -lt | less ## find file 100 days ago
- cd /backup4/ftp/companyName && find prc243d -type f -mtime +490 | rsync -av --files-from=- . 2009/ ##backup before 20091231
- find . -mtime 0 # find files modified between now and 1 day ago
# (i.e., within the past 24 hours)
find . -mtime -1 # find files modified less than 1 day ago
# (i.e., within the past 24 hours, as before)
find . -mtime 1 # find files modified between 24 and 48 hours ago
find . -mtime +1 # find files modified more than 48 hours ago
find . -mmin +5 -mmin -10 # find files modified between # 6 and 9 minutes ago
沒有留言:
張貼留言