Похожие чаты

Hi all 👋 Does anyone know how to make a

multi-line expression with sed? I'm trying to do the following but it fails with sed: -e expression #1, char 22: unterminated `s' command

29 ответов

22 просмотра

sed -i -e 'expr1' \ -e 'expr2' <file>

How do I unsee this? Please send help.

Egidio- Автор вопроса
Egidio- Автор вопроса
void
sed -i -e 'expr1' \ -e 'expr2' <file>

It doesn't fit my case. I have a file containing placeholder and want to replace that with a multi-line string

Egidio
Is it that bad?

It can't possibly be good when done in bash.

Egidio
It doesn't fit my case. I have a file containing p...

Then why do you insert placeholder after the multi-line string?

Egidio
It doesn't fit my case. I have a file containing p...

oh i thought you wanted muliti expression with on sed command

Egidio- Автор вопроса
Alexander Gnatyuk
Then why do you insert placeholder after the multi...

I have an array in a JS file that I need to fill with a long object, so I do something like array: [ PLACEHOLDER ], and then sed -i 's|PLACEHOLDER|${ITEM}PLACEHOLDER|g' file.js for each $ITEM I have to put in the array

Egidio
I have an array in a JS file that I need to fill w...

Just put them together in bash and then replace once at the end.

Egidio- Автор вопроса
Alexander Gnatyuk
Just put them together in bash and then replace on...

That's not the issue. The issue is that in my example $ITEM is a multi-line string, and that bothers sed, it seems

Egidio- Автор вопроса
void
screenshot is this close to want you need

It actually is, and that's what I'm doing alright, right? I have a multi-line string in a variable $ITEM. Do I need to escape the new-lines? If so, how?

Egidio
It actually is, and that's what I'm doing alright,...

i dont know until i see what string those variables contain

Egidio- Автор вопроса

This is the real case

If you need to do multiline sed it's time to reconsider using sed

Egidio- Автор вопроса
Egidio
OK, what would you suggest instead?

Looks like JSON, so just use a json parser to redo it.

Egidio- Автор вопроса
Egidio
Unfortunately it's a Javascript file

Can't you just deploy the file in its entirety?

Egidio- Автор вопроса

No, the Bash script has to modify the Javascript script at runtime, before the application starts

Egidio- Автор вопроса
void
screenshot is this close to want you need

The only solution would be to write a single line without new-lines characters, but why this works and in my case, where the expressions is a variable with new-lines, doesn't?

Egidio
The only solution would be to write a single line ...

Just use perl for multiline, but seriously reconsider if you can't do or push for a proper deploy

Try using envsubst

Egidio- Автор вопроса
Alexander Gnatyuk
Try using envsubst

It's not present in my env. Do you know how to do it with perl maybe?

Egidio
It's not present in my env. Do you know how to do ...

https://gitlab.com/C0rn3j/arch/blob/703dae958dab40002bf7b9bb85970f0d00d57acd/install.sh#L358

Egidio- Автор вопроса
Martin Rys
https://gitlab.com/C0rn3j/arch/blob/703dae958dab40...

I can't install it in the deployment env 😔 I'll try with perl when I can and see what I can do

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта