파일에서 주어진 텍스트를 찾아 지정된 경로에서 바꾸고 텍스트를 바꾼 후 해당 파일의 이름 바꾸기 주어진 단어로. sed를 사용하는 동안 허가가 거부되었습니다. 내 스크립트 내가 아래에 오류가 발생하고이셸 스크립트 및 sed 사용 - 파일에서 단어 찾기 및 바꾸기 및 파일 이름 바꾸기
`echo "Please Insert the path of the folder"
read input_variable
read -p "You entered: $input_variable is correct y/n " yn
read -p "Enter the word to find = " word
read -p "Enter word to replace = " replace
case $yn in
[Yy]*) find "${input_variable}" -type f -iname "${word}.*" | while read filename; do "`echo "${filename}" | sed -i 's/$word/$replace/g' ${filename}| sed -i 's/\$word/\$replace/' ${filename}`"; done ;;
[Nn]*) exit;;
*) echo "Please answer yes or no.";;
esac`
과 같은
bulk_rename.sh : 34 : bulk_rename.sh : 권한이
어떤 제안이 거부? @vijay에 의해 제안 이제 스크립트
echo "Please Insert the path of the folder"
read input_variable
read -p "You entered: $input_variable is correct y/n " yn
read -p "Enter the word to find = " word
read -p "Enter word to replace = " replace
case $yn in
[Yy]*) find "${input_variable}" -type f -iname "${word}.*" | while read filename; do
perl -pi -e 's/$word/$replace' ${filename}
mv ${filename} $word; done;;
[Nn]*) exit;;
*) echo "Please answer yes or no.";;
esac
를 업데이트 한 후
나는 다음과 같은
대체 교체를 얻고 것은 -e 줄에서 종료되지 1
이것은 내가 chmod 출력을 표시 할 때 얻을 수있다.
[email protected]:~/Documents/blog$ chmod +x bulk_rename.sh ; /bin/ls -l bulk_rename.sh
chmod +x bulk_rename.sh ; /bin/ls -l bulk_rename.sh
+ chmod +x bulk_rename.sh
+ /bin/ls -l bulk_rename.sh
-rwxrwxr-x 1 abc abc 1273 Aug 1 16:51 bulk_rename.sh
'chmod를 + X bulk_rename.sh' – devnull
을 요구 한이 질문의 도움으로 해당 파일을 편집 할 수있는 권한이 없습니다. – devnull
빠른 답장을 보내 주셔서 감사합니다. @devnull 또한 권한을 변경해 보았습니다. –