I have one file exa1.txt
which contains the following text:
wget -O backward-cpp-$VERSION.tar.gz https://github.com/bombela/backward-cpp/archive/v$VERSION.tar.gz
tar xf backward-cpp-$VERSION.tar.gz
testString
I need to append/insert following line using linux sed
command
sed -i '/uctx->uc_mcontext.regs->nip/a \#elif defined(__s390x__)\n\ error_addr = reinterpret_cast<void*>(uctx->uc_mcontext.psw.addr);' backward-cpp-$VERSION/backward.hpp
I tried the following
Option-1
sed -i '/tar xf backward-cpp-$VERSION.tar.gz/a\
sed -i '/uctx\->uc_mcontext.regs\->nip/a \\#elif defined\(__s390x__\)\n\ error_addr = reinterpret_cast<void*>(uctx->uc_mcontext.psw.addr);' backward-cpp-$VERSION/backward.hpp' exa1.txt /$BUILDDIR/envoy/ci/build_container/build_recipes/backward.sh
Option-2
sed -i -e 's/testString/sed -i '/uctx->uc_mcontext.regs->nip/a \\#elif defined\(__s390x__\)\\n\\ error_addr = reinterpret_cast<void*>\(uctx->uc_mcontext.psw.addr\);' backward-cpp-$VERSION/backward.hpp/g' exa1.txt
but I get this error
-bash: nip/a: No such file or directory
-bash: backward-cpp-$VERSION/backward.hpp/g: No such file or directory