我正在尝试使用sed命令将@sys
替换为amd64_linux26_rh5.64
。
#!/bin/ksh
file_path="/xxx/xxx/xxx/@sys/xxx"
os="amd64_linux26_rh5"
osver="amd64_linux26_rh5.64"
sys="@sys"
echo "osver: $osver"
echo "old file_path is : $file_path"
file_path=$(echo "$file_path" | sed "s/$sys/${osver}/")
echo "new file_path is : $file_path"
但得到输出:
osver: amd64_linux26_rh5.64
old file_path is : /xxx/xxx/xxx/amd64_linux26_rh5/xxx
new file_path is : /xxx/xxx/xxx/amd64_linux26_rh5/xxx
我也尝试了file_path=$(echo "$file_path" | sed "s/$sys/${os}\.64/")
,但输出结果不同。
提前致谢!