วันพุธที่ 6 ตุลาคม พ.ศ. 2553

find command with -exec options

find command is quite a handy tool for file searching. It can also include an command to execute for matched file with

1) -exec command ;
2) -exec command {} +

Both are different.
Let say you have 3 files, a b c in the directory.

#find . -exec echo '{}' >> tmp1 \;
output in tmp1 will be :
.
./b
./a
./c
./tmp1

#find . -exec echo '{}' >> tmp2 \+;
output in tmp2 will be :
a b c

with + all matched file will be append and execute once.
with ; all matched file will be execute for each matching.

ไม่มีความคิดเห็น:

แสดงความคิดเห็น