ersetzen Wir haben eine ASCII-Art wie folgtsed einen Text mit Text in Variable
ART _____
ART | __ \
ART | |__) |__ ___ _ __
ART | ___/ _ \/ _ \ '__|
ART | | | __/ __/ |
ART |_| \___|\___|_|
ART
ART
wir eine Variable $ haben {art} = "123456" und wollen ART mit $ ersetzen {art}, so das System wird die Standardausgabe wie diese
123456 _____
123456 | __ \
123456 | |__) |__ ___ _ __
123456 | ___/ _ \/ _ \ '__|
123456 | | | __/ __/ |
123456 |_| \___|\___|_|
123456
123456
ich habe versucht, diese drucken, wie dieser Beitrag
sed -i "s/ART/${art}/g" ascii-art
das schlägt folgende Fehlermeldung erscheint:
sed: -e expression #1, char 6: unterminated `s' command
Ich bin in 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 kehrt:
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.
Irgendwelche Gedanken?
Danke!
funktioniert gut für mich. Probieren Sie 'sed -i' "" s/ART/$ {art}/g "ascii-art' aus - notieren Sie die zusätzlichen Zitate nach -i. – SiKing
Dies würde passieren, wenn der Wert von $ art ein '/' -Zeichen enthält. Aber '123456' sollte kein Problem sein. – Barmar
@SiKing Es gibt keinen Unterschied zwischen '-i' und' -i "" '. Eine leere Zeichenfolge wird einfach von der Shell entfernt. – Barmar