相关疑难解决方法(0)

是否可以安全地使用`find -exec sh -c`?

我正在尝试将findtoecho 0用于某些文件,但显然这仅适用于sh -c

find /proc/sys/net/ipv6 -name accept_ra -exec sh -c 'echo 0 > {}' \;
Run Code Online (Sandbox Code Playgroud)

但是使用sh -cwithfind -exec让我觉得很不安,因为我怀疑引用问题。我稍微摆弄了一下,显然我的怀疑是有道理的:

  • 我的测试设置:

    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 …
    Run Code Online (Sandbox Code Playgroud)

shell find

40
推荐指数
1
解决办法
1万
查看次数

标签 统计

find ×1

shell ×1