UNIX/コマンド/検索/find


% find . -name '*.c'
% find [path...] [option] [expression] [action]
Table of Contents

% find . -name 'test.txt'

% find . -name '*.txt'

%  find . -name '*txt' -exec echo \"\{\}\" \;
./Hoge hoge.txt
./hoge.txt
"./Hoge hoge.txt"
"./hoge.txt"
% find $HOME/. -name "#*" -or -name ".*~" -or -name "*~" -exec rm {} \;

% find $HOME/.  -name "#*" -or -name ".*~" -or -name "*~" | xargs rm

% find . -name "[file_pattern]" | xargs grep [pattern]
% find . -name "[file_pattern]" | xargs grep -l [pattern]
% find . -name "[file_pattern]" -print0 | xargs -0 grep -l [pattern]

% find [path] -type f -name '[file_pattern]' | xargs grep -l '[対象文字列]' | xargs sed -i.bak 's/[対象文字列]/[置換後文字列]/g'

% find . -name "[file_pattern]" -prune -o -print
% find . -name ".svn" -prune -o -print | xargs zip a.zip

xrea