我正在尝试将find
toecho 0
用于某些文件,但显然这仅适用于sh -c
:
find /proc/sys/net/ipv6 -name accept_ra -exec sh -c 'echo 0 > {}' \;
Run Code Online (Sandbox Code Playgroud)
但是使用sh -c
withfind -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)我希望能够xargs
在命令的不同部分执行多个参数。
例如,以下内容:
echo {1..8} | xargs -n2 | xargs -I v1 -I v2 echo the number v1 comes before v2
Run Code Online (Sandbox Code Playgroud)
我希望它会回来
the number 1 comes before 2
the number 3 comes before 4
Run Code Online (Sandbox Code Playgroud)
... 等等
这是可以实现的吗?我怀疑我的多次使用-I
是不正确的。