0
我們有一個ASCII藝術像下面SED替換文本的文本變量
ART _____
ART | __ \
ART | |__) |__ ___ _ __
ART | ___/ _ \/ _ \ '__|
ART | | | __/ __/ |
ART |_| \___|\___|_|
ART
ART
我們有一個變量$ {藝術} =「123456」,想用$ {藝術}來代替藝術,所以該系統將打印標準輸出這樣
123456 _____
123456 | __ \
123456 | |__) |__ ___ _ __
123456 | ___/ _ \/ _ \ '__|
123456 | | | __/ __/ |
123456 |_| \___|\___|_|
123456
123456
我曾經嘗試這樣做,因爲這表明後
sed -i "s/ART/${art}/g" ascii-art
以下錯誤信息顯示出來:
sed: -e expression #1, char 6: unterminated `s' command
我在Linux ip-10-22-37-149 4.4.8-20.46.amzn1.x86_64 #1 SMP Wed Apr 27 19:28:52 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux (Amazon EC2)
的sed --version回報:
GNU sed version 4.2.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.
GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.
E-mail bug reports to: <[email protected]>.
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
有什麼想法?
謝謝!
工作正常,我。試試'sed -i「」「s/ART/$ {art}/g」ascii-art' - 注意-i後的額外引號。 – SiKing
如果'$ art'的值包含'/'字符,則會發生這種情況。但'123456'不應該是一個問題。 – Barmar
@SiKing'-i'和'-i「」'沒有區別。一個空字符串被shell簡單地刪除。 – Barmar