sedで実行できます。私はそれがより便利にするために、ラッパー関数を、次の使用します。このスクリプトを実行しているユーザーがパスワードなしでsudoを使用することが可能であるべきで
replace_string() {
while :; do
case $1 in
file=?*) local file=${1#*=} ;;
replace=?*) local replace=${1#*=} ;;
with=?*) local with=${1#*=} ;;
*) break ;;
esac
shift
done
sudo sed -i -- "s/$replace/$with/ig" $file
}
replace_string file='/etc/apache2/sites-enabled/000-default.conf' \
replace='.*DocumentRoot.*' \
with='DocumentRoot path-to-your-document-root'
replace_string file='/etc/apache2/apache2.conf' \
replace='.*DocumentRoot.*' \
with='DocumentRoot "path-to-your-document-root"'
マインド。
はい、「nano」のようなファイルを編集するには、コマンドラインエディタを使用する必要があります。 – error2007s