简体   繁体   中英

Linux Shell scripting sed command

sed -r -i -e "s/AppId/$a/" -e "s/AccessToken/$b/" FacebookApi > /script/newapp

通过发出此命令,为什么程序无法执行,您能解决这个问题吗?

sed is an editor, not a shell interpretor. It execute SED instruction like subistitute for s/// but not batch or binary of other form (than sed instruction). Execution stay at calling shell level and management (like variable substition between double quote in a sed instruction string that is treated before sed receive the full instruction)

The command is executed. As you specified -i it is modifying the specified file in place (and not generating any output).

From the sed man page:

 -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. 

As sed is directly modifying FacebookApi standard output will be empty (as the file /script/newapp )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM