![](/img/trans.png)
[英]How to find all .sh files and make them executable using bash in linux?
[英]bash - find all .bashrc files and append to them
我需要找到所有.bashrc文件并将“MYSQL_HISTFILE = / dev / null”附加到它,以修复问题。 有很多.bashrc文件,所以我可以这样做:
find / -type f -name ".bashrc" -exec echo "export MYSQL_HISTFILE=/dev/null" >> {} \;
>>
由原始shell进程执行,它不能使用find
替换。 并且find
不会通过shell运行它的命令,因此它本身不能进行输出重定向。
您需要显式执行bash
以便在命令中使用重定向。
find / -type f -name '.bashrc' -exec bash -c 'echo export MYSQL_HISTFILE=/dev/null >> "{}"' \;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.