4. 2.オプションの種類 4
オプション
オプション 効果
効果
-regex および -iregex の後の正規表現を、基本正規表現(BRE)でなく拡張
-regex および -iregex の後の正規表現を、基本正規表現(BRE)でなく拡張
E
E 正規表現として解釈。regexp_flags に 0001 を立てる。
正規表現として解釈。regexp_flags に 0001 を立てる。
直接指定された有効なシンボリックリンクを処理するときだけ、 リンク先をたど
直接指定された有効なシンボリックリンクを処理するときだけ、 リンク先をたど
H
H る。それ以外はたどらない。L、Pとは排他的。
る。それ以外はたどらない。L、Pとは排他的。
有効なシンボリックリンクをたどる。シンボリックリンクが無効なときはたどらな
有効なシンボリックリンクをたどる。シンボリックリンクが無効なときはたどらな
L
L い。H、Pとは排他的。
い。H、Pとは排他的。
シンボリックリンクをまったくたどらない。デフォルトの動作。H、Lとは排他的。
シンボリックリンクをまったくたどらない。デフォルトの動作。H、Lとは排他的。
P
P
xargs的に無効な文字(スペース、タブ、LF、バックスラッシュ、シングルクォー
xargs的に無効な文字(スペース、タブ、LF、バックスラッシュ、シングルクォー
X
X ト、ダブルクォート)を含むパスは警告を出して、処理しない。
ト、ダブルクォート)を含むパスは警告を出して、処理しない。
深さ優先探索を行う。かといってデフォルトが幅優先かというとそうでもなく、デ
深さ優先探索を行う。かといってデフォルトが幅優先かというとそうでもなく、デ
d
d フォルトは”深さ優先探索だけどディレクトリを先に処理する版”。
フォルトは”深さ優先探索だけどディレクトリを先に処理する版”。
find が探索するファイル階層を指定する。引数を取る。が、-f自体書かなくても
find が探索するファイル階層を指定する。引数を取る。が、-f自体書かなくても
f
f 同じ。
同じ。
探索時に、ディレクトリ内のファイルをアルファベット順に取得する。
探索時に、ディレクトリ内のファイルをアルファベット順に取得する。
s
s
探索開始ディレクトリと違うファイルシステムを探索しないようにする。
探索開始ディレクトリと違うファイルシステムを探索しないようにする。
x
x
5. 3.PLANの作成 5
関数 find_formplan (find.c)
PLAN * find_formplan(char *argv[])
でPLAN(リスト)を作成
PLAN *plan
PLAN *plan PLAN *tail
PLAN *tail
next
next next
next -print
-print
-exec
-exec next
next
-ok
-ok
・最後のPLAN(*tail)は必ず
-print、-exec、-okのどれかになる
(find.c L117辺り~)
・print、exec、okが指定されていないとき
勝手に'('')'付きで -print が補われる
・'('や')'も一つのPLANになる
6. 4.(),!,orの処理 6
作成したリストから()、!、orを処理する。
まず()を取り除く(サブプラン化する)。
$ find . ( ! -newer hoge -or -user foo ) -print
$ find . ( ! -newer hoge -or -user foo ) -print
( next
( next !
! next
next -newer hoge next
-newer hoge next -or
-or next
next
-user foo next
-user foo next ) next
) next -print next
-print next
()除外
()除外
next
next -print
-print next
next
expr
expr
p_data
p_data
!
! next
next -newer hoge next
-newer hoge next -or
-or next
next -user foo
-user foo next
next
7. 4.(),!,orの処理 7
次に!の否定先をサブプランにする。
next
next -print
-print next
next
expr
expr
p_data
p_data
! next
! next -newer hoge next
-newer hoge next -or next
-or next -user foo next
-user foo next
!処理
!処理
next
next -print
-print next
next
expr
expr
p_data
p_data
next
next -or next
-or next -user foo next
-user foo next
!
!
p_data
p_data -newer hoge next
-newer hoge next
8. 4.(),!,orの処理 8
最後に-orを処理する。
next
next -print
-print next
next
expr
expr
p_data
p_data
next
next -or next
-or next -user foo next
-user foo next
!
!
p_data
p_data -newer hoge next
-newer hoge next
-or処理
-or処理
next
next
expr
expr -print next
-print next
p_data
p_data next
next
next
next
-or p_data[0]
-or p_data[0] !
!
p_data
p_data -newer hoge next
-newer hoge next
p_data[1]
p_data[1]
-user foo next
-user foo next