![](/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.