[英]Find and replace inside a string variable using sed command - shell scripting
[英]Linux Shell scripting sed command
sed -r -i -e "s/AppId/$a/" -e "s/AccessToken/$b/" FacebookApi > /script/newapp
通過發出此命令,為什么程序無法執行,您能解決這個問題嗎?
sed是編輯器,而不是shell解釋器。 它執行SED指令,例如為s///
替代,但不執行其他形式的批處理或二進制形式(而不是sed指令)。 執行停留在調用外殼程序級別和管理上(例如,在sed接收完整指令之前處理的sed指令字符串中雙引號之間的變量替換)
該命令被執行。 如您指定的-i
它正在修改指定的文件(並且不生成任何輸出)。
在sed
手冊頁中:
-i extension Edit files in-place, saving backups with the specified extension. If a zero-length extension is given, no backup will be saved. It is not recommended to give a zero-length extension when in-place editing files, as you risk corruption or partial content in situations where disk space is exhausted, etc.
由於sed
是直接修改的, FacebookApi
標准輸出將為空(如文件/script/newapp
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.