Я использую это как str_replace для каждого файла в папке после разархивирования архива во временной папке
find "$tmp" -type f | xargs sed -i "s/${targetsubstring}/${newsubstring}/g"
но я получаю эту ошибку:
sed: can't read /tmp/tmp.Q18p8BRYcc/steam: No such file or directory
sed: can't read engine.txt: No such file or directory
Мой TMP Var:
tmp =
mktemp -d
Что я делаю неправильно?
ОБНОВИТЬ
archive=`readlink -e $1` #First param is tar archive without file structure (only text files inside)
targetsubstring=$2 #Substring to replace
newsubstring=$3 #Substring to replaced by
tmp=`mktemp -d` #Create a room to unzip our archive
if [ -f "$archive" ]; #Check if archive exist
then
echo "Well done! (And yeah, I know about [ ! -f '$1' ], but where would be the fun?)" >/dev/null
else
echo "File doesn't exist! Terminating program." >&2
exit 1
fi
tar xvf "$archive" -C "$tmp" >/dev/null #Unzip archive to temp folder
find "$tmp" -type f | xargs sed -i "s/${targetsubstring}/${newsubstring}/g" #For every file do str_replace (There is a problem somwhere)
cd "$tmp"
tar -zcf "$archive" . #Zip this to original file (I don't want any folder in my tar file)