hajichan.net technical version
トップページ >> unixコマンドメモ(検索)

unixコマンドメモ

便利なコマンド使用例、使えそうなコマンド、ワンライナーなどなど・・・忘れない程度に記載してみました。どのunixプラットホームにも使用できると思います(多分・・・)。

検索

findコマンド関連

複数のファイルの中から該当する文字列を検索

% (find [dir] -name [string] > /dev/tty) >& /dev/null
% (find [dir] -type f -print | xargs grep [string] > /dev/tty) >& /dev/null
% find ./ -name "*.html" -o -name "*.htm" -exec grep [string] {} \;

10日以上前に変更されたファイルを検索

% find ./ \( -mtime +10 -a \! -name "*.gz" \) -print
% find ./ -mtime +10 \! -name "*.gz"

ファイル名にtextという文字列が含まれるファイルにおいて、text.static以外を検索

% find ./ \! -name text.static -name "text.*" -mtime +2 -print
% find ./ -mtime +2 \! -name text.static -name "text.*"

backディレクトリは検索せず

% find ./ -name back -prune -o -mtime +1 \! -name text.static -name "text.*"

grepコマンド関連

コメント行以外を表示

% grep -v "^#" /etc/inetd.conf | sed '/^$/d'

リアルタイムに特定IPアドレスからのアクセスのみを表示

% tail -f access.log | grep 192.168.1.10
ページのトップへ戻る