Ben kullanmaya çalışıyorum findiçin echo 0bazı dosyalar halinde, ancak görünüşe göre bu sadece çalışır sh -c:
find /proc/sys/net/ipv6 -name accept_ra -exec sh -c 'echo 0 > {}' \;
Ama kullanarak sh -cile find -execSorunlarım alıntı zanlısı çünkü markaların beni çok huzursuz hissediyorum. Bununla biraz uğraştım ve görünüşe göre şüphelerim haklı çıktı:
Test kurulumum:
martin@dogmeat ~ % cd findtest martin@dogmeat ~/findtest % echo one > file\ with\ spaces martin@dogmeat ~/findtest % echo two > file\ with\ \'single\ quotes\' martin@dogmeat ~/findtest % echo three > file\ with\ \"double\ quotes\" martin@dogmeat ~/findtest % ll insgesamt 12K -rw-rw-r-- 1 martin martin 6 Sep 17 12:01 file with "double quotes" -rw-rw-r-- 1 martin martin 4 Sep 17 12:01 file with 'single quotes' -rw-rw-r-- 1 martin martin 4 Sep 17 12:01 file with spacesfind -execOlmadan kullanmak sorunsuz çalışıyorsh -cgibi görünüyor - burada alıntı yapılması gerekmiyor:martin@dogmeat ~ % find findtest -type f -exec cat {} \; one two threeAma kullandığımda
sh -c{}bir çeşit alıntı yapılması gerekiyor gibi görünüyor:martin@dogmeat ~ % LANG=C find findtest -type f -exec sh -c 'cat {}' \; cat: findtest/file: No such file or directory cat: with: No such file or directory cat: spaces: No such file or directory cat: findtest/file: No such file or directory cat: with: No such file or directory cat: single quotes: No such file or directory cat: findtest/file: No such file or directory cat: with: No such file or directory cat: double quotes: No such file or directoryÇift tırnak, dosya adı çift tırnak içermediği sürece çalışır:
martin@dogmeat ~ % LANG=C find findtest -type f -exec sh -c 'cat "{}"' \; one two cat: findtest/file with double: No such file or directory cat: quotes: No such file or directoryTek tırnak, hiçbir dosya adı tek tırnak içermediği sürece çalışır:
martin@dogmeat ~ % LANG=C find findtest -type f -exec sh -c "cat '{}'" \; one cat: findtest/file with single: No such file or directory cat: quotes: No such file or directory three
Her durumda işe yarayan bir çözüm bulamadım. Orada bir şey bakan ediyorum, yoksa kullandığını sh -ciçinde find -execdoğal olarak tehlikelidir?
shyerini ise çok çalışır, yer tutucu çeşit gibi görünüyor_örneğin - Eğer bash internals aramak istiyorsanız çok kullanışlı:find /tmp -name 'fil*' -exec bash -c 'printf "%q\n" "$1"' _ {} \;. Ama bunun nerede belgelendiğini bilen var mı?