sudo �R�}���h���g�p����Ƃ��� �p�X���[�h����Ȃ��悤�ɂ���ݒ�̃����ł��B
sudo �̐ݒ�t�@�C���� /etc/sudoers �ł��� �ҏW����Ƃ��́A���ڊJ���̂ł͂Ȃ� visudo �Ƃ����R�}���h���g�p���܂��B
ALL ALL=(ALL) NOPASSWD: ALL
������A���[�U�A�z�X�g�A�����A�R�}���h�Ȃ̂ł����A �R�}���h�� NOPASSWD: �ƕt���邱�ƂŃp�X���[�h��������Ȃ��Ȃ�܂��B
����̃��[�U�ɑ��� ����̃R�}���h�݂̂����������ꍇ�� ���̂悤�ɋL�q���܂��B
user1 ALL=(ALL) NOPASSWD: /etc/init.d/httpd
����� user1 �� httpd �̎��s���ł���悤�ɂȂ�܂��B
Linux �����̃e�L�X�g�t�@�C���̕�������ꊇ�� �u�����邽�߂̃V�F���X�N���v�g������Ă݂܂����B
#!/bin/bash # ========================================================== # �����t�@�C���ꊇ�u���R�}���h # ----------------------------------------------------- # create : 2010/01/21 Studio ODIN # update : # ========================================================== # --- init --------------------------------------------- COMMAND_NAME=bulk_replace CUR_DIR=`pwd` # -- args ---------------------------------------------- TARGET_WORD=$1 REPLACE_WORD=$2 TARGET_DIR=$3 # -- args check ---------------------------------------- if [ "$TARGET_WORD" = "" ]; then echo "target word is nothing." >&2 echo "Usage: $0 targetword replaceword [targetpath]" >&2 exit 1 fi if [ "$REPLACE_WORD" = "" ]; then echo "replace word is nothing." >&2 echo "Usage: $0 targetword replaceword [targetpath]" >&2 exit 1 fi if [ "$TARGET_DIR" = "" ]; then TARGET_DIR=. fi # -- execute ------------------------------------------- grep -R -l "${TARGET_WORD}" "${TARGET_DIR}" | while read file do tfile=`mktemp -u` cp -f -p $file $tfile > /dev/null 2>&1 if [ $? -eq 0 ]; then sed -e "s/${TARGET_WORD}/${REPLACE_WORD}/g" $file > $tfile if [ $? -ne 0 ]; then echo "Warning: failed write '$file'" fi mv -f $tfile $file > /dev/null 2>&1 if [ $? -ne 0 ]; then echo "Warning: failed rewrite '$file'" rm -f $tfile > /dev/null 2>&1 fi else echo "Warning: failed copy '$file'" fi done # -- normal end ---------------------------------------- cd $CUR_DIR exit 0 # ========================================================== # shell end # location: /usr/local/bin/bulk_replace # ==========================================================
���s����ꍇ�́A�p�X�̎w��ȂǑ厖�ȃt�@�C���� ��ςȂ��ƂɂȂ�Ȃ��悤�ɋC��t���Ă��������B �i���ȐӔC�ł��肢���܂��j
����ȃR�}���h�́A���łɂ���悤�ȋC�����܂��� �����ŏ������l���č���Ă݂�͖̂ʔ����Ǝv���܂��B