シェルスクリプトを呼び出すMakefielがあります。そのシェルスクリプトの中に私は次のsedコマンドを持っています:シェルスクリプト内でsedを使用して、一致するテキストを別のファイルの内容に置き換えます。
sed -e '/.section\t.text/{' -e 'r anotherfile.s' -e 'd' -e '}' input.s > output.s
これは動作しません。 これをターミナルに直接実行するとうまく動作します。 ファイル内の ".section .text"行を検索し、別のファイルと置き換えたいとします。 ここで何が間違っていますか?
input.s
.section .data
.addressing Word
_A:
.data.32 0
.section .text
.addressing Word
_main:
LW %GPR27, _C(%GPR0)
NOP
anotherfile.s sedの
.addr_space 32 ; address space is 2^32
.addressing Byte ; byte addressing (default)
.bits_per_byte 8 ; 1 byte consists of 8 bit (default)
.endian Big ; Big endian (default)
.section .text
.org 0x00000000
output.s(このようにする必要があります)
.section .data
.addressing Word
_A:
.data.32 0
.addr_space 32 ; address space is 2^32
.addressing Byte ; byte addressing (default)
.bits_per_byte 8 ; 1 byte consists of 8 bit (default)
.endian Big ; Big endian (default)
.section .text
.org 0x00000000
.addressing Word
_main:
LW %GPR27, _C(%GPR0)
NOP
[の可能性のある重複バッシュsedのファイルとテキストを置き換えますコンテンツ](https://stackoverflow.com/questions/31056599/bash-sed-replace-text-with-file-content) – Cyrus
親愛なる@Cyrusは、上記のコマンドを端末で使用しています。しかし、シェルスクリプト内でこのコマンドを実行すると、output.sはinput.sと同じです。 – Sajjad
質問するときは、何か「うまくいきません」と言うことはありません。 、エラーメッセージ、コアダンプなどのコードを修正するための助けを求めることは、あなたの車を整備士に持ち帰り、整備士に「うまく行かない」と言って、修理を期待しているようなものです。 –