Я все еще работаю в этом маленьком скрипте, но все еще имею проблемы. Получение ошибкирекурсивное изменение sed grep и sed
sed: no input files
Я думаю, что проблема находится на:
for i in `cat sed_output.txt` do sed 's/$oldstr/$newstr/g' > sed_output_new_old_string.txt done
echo "Enter string to be replaced"
read OLDSTRING
echo "Enter string to be placed"
read NEWSTRING
oldstr=$OLDSTRING #string to be replaced
newstr=$NEWSTRING #new string to be placed
echo "Enter folder path where we will find the string"
read FOLDERPATH
### grep oldstring and output it in grep_output.txt
grep -rl $oldstr $FOLDERPATH > grep_output.txt
### spaces or special characters on filenames, use sed to enclose them with quote
for i in `cat grep_output.txt`
do sed -e "s/'/'\\\\''/g;s/\(.*\)/'\1'/" grep_output.txt > sed_output.txt
done
for i in `cat sed_output.txt`
do sed 's/$oldstr/$newstr/g' > sed_output_new_old_string.txt
done
я сделал для I в 'кошки grep_output.txt' сделать СЕПГ -i "s/$ oldstr/$ NewStr/г" $ я> sed_output_new_old_string.txt сделано – jmazaredo
Вам не нужно делать' cat' , 'sed' по умолчанию анализирует файл по строкам. Вы можете просто сделать «sed» s/$ oldstr/$ newstr/g «grep_output.txt> новый файл». Вам не нужна опция -i', если вы перенаправляете вывод в новый файл. Это только для изменений в файле. –