linux終端中依次輸入2條命令:
sed -i "s/`cat TBCxiug.dat |awk '{print $2 }'|awk 'NR==74{print}'`/`cat a.txt |awk '{print $2 }'|awk 'NR==1{print}'`/g" TBCxiug.dat
/opt/software/.../nessus /opt/software/.../license.txt /home/.../TBCxiug probabilistic verbose z
能執行并得到相應結果(不要關注第二條命令,它是呼叫名為nessus的軟體計算一個案例)
我把上面2條命令寫入file.txt,
#!/bin/sh
sed -i "s/`cat TBCxiug.dat |awk '{print $2 }'|awk 'NR==74{print}'`/`cat a.txt |awk '{print $2 }'|awk 'NR==1{print}'`/g" TBCxiug.dat
/opt/software/.../nessus /opt/software/.../license.txt /home/.../TBCxiug probabilistic verbose z
并chmod +x file.txt 變成可執行后, ./file.txt運行后,報錯如下:
/opt/software/NESSUS-9.5/bin/Linux/nessus: No such file or directory
sed: can't read /home/xiaoyq/Desktop/NESSUS_Temp/TBCxiug: No such file or directory
sed: can't read probabilistic: No such file or directory
sed: can't read verbose: No such file or directory
sed: can't read z: No such file or directory
求分析原因,求解決
uj5u.com熱心網友回復:
sed沒有找到檔案或者目錄,你看下是不是路徑問題,檔案的路徑最好使用絕對路徑uj5u.com熱心網友回復:
但是我一條一條輸命令時并沒有出錯,而且實際上第二條命令與sed都沒關系了
uj5u.com熱心網友回復:
TBCxiug.dat在那個地方,腳本又在哪??放一起的么uj5u.com熱心網友回復:
放在同一個檔案夾中的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/121307.html
標籤:專題技術討論區
上一篇:Linux下的撥號上網腳本
下一篇:getifaddrs函式例外問題
