在临时文件夹中解压缩存档后,我将其用作文件夹中每个文件的 str_replace
find "$tmp" -type f | xargs sed -i "s/${targetsubstring}/${newsubstring}/g"
Run Code Online (Sandbox Code Playgroud)
但我收到此错误:
sed: can't read /tmp/tmp.Q18p8BRYcc/steam: No such file or directory
sed: can't read engine.txt: No such file or directory
Run Code Online (Sandbox Code Playgroud)
我的 tmp 变量:
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 …Run Code Online (Sandbox Code Playgroud)