Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

33%
+1 −4
Q&A Substituting text in a sed like manner but with a richer format

I have the following problems working with sed: It doesn't allow multiline operations (thus, no indentations, no nesting) It is generally obligatory to wrap entire commands in quote marks (sed ...

1 answer  ·  posted 3y ago by deleted user  ·  last activity 3y ago by user53100‭

Question sed text-processing
#4: Post edited by (deleted user) · 2021-09-20T12:17:02Z (about 3 years ago)
  • I have the following problems working with `sed`:
  • * It doesn't allow multiline operations (thus, no indentations, no nesting)
  • * It is generally obligatory to wrap entire commands in quote marks (`sed "SED_COMMAND"` FILE) even if the command itself contains quote marks.
  • Without these problems I could format a long liner such as `sed -i "s/\$to = ".*";$/\$to = example@example.com;/g" PATH` as in this pseudocode:
  • ```shell
  • sed -i
  • A
  • \$to = ".*";$
  • B
  • \$to = example@example.com;
  • G
  • PATH
  • ```
  • * A means "from"
  • * B means "to"
  • * G means "global"
  • Since `sed` doesn't work this way, how could I achieve a similar syntax in the shell? Perhaps by using Python? Perl? Something else?
  • I have the following problems working with `sed`:
  • * It doesn't allow multiline operations (thus, no indentations, no nesting)
  • * It is generally obligatory to wrap entire commands in quote marks (`sed "SED_COMMAND" FILE`) even if the command itself contains quote marks.
  • Without these problems I could format a long liner such as `sed -i "s/\$to = ".*";$/\$to = example@example.com;/g" PATH` as in this pseudocode:
  • ```shell
  • sed -i
  • A
  • \$to = ".*";$
  • B
  • \$to = example@example.com;
  • G
  • PATH
  • ```
  • * A means "from"
  • * B means "to"
  • * G means "global"
  • Since `sed` doesn't work this way, how could I achieve a similar syntax in the shell? Perhaps by using Python? Perl? Something else?
#3: Post edited by (deleted user) · 2021-09-19T11:30:45Z (about 3 years ago)
  • I have the following problems working with `sed`:
  • * It doesn't allow multiline operations (thus, no indentations, no nesting)
  • * It is generally obligatory to wrap entire commands in quote marks (`sed "SED_COMMAND"` FILE) even if the command itself contains quote marks
  • Without these problems I could format a long liner such as `sed -i "s/\$to = ".*";$/\$to = example@example.com;/g" PATH` as something like this pseudocode:
  • ```shell
  • sed -i
  • A
  • \$to = ".*";$
  • B
  • \$to = example@example.com;
  • G
  • PATH
  • ```
  • * A means "from"
  • * B means "to"
  • * G means "global"
  • Since `sed` doesn't work this way, how could I achieve a similar code in the shell? Perhaps by using Python? Perl? Something else?
  • I have the following problems working with `sed`:
  • * It doesn't allow multiline operations (thus, no indentations, no nesting)
  • * It is generally obligatory to wrap entire commands in quote marks (`sed "SED_COMMAND"` FILE) even if the command itself contains quote marks.
  • Without these problems I could format a long liner such as `sed -i "s/\$to = ".*";$/\$to = example@example.com;/g" PATH` as in this pseudocode:
  • ```shell
  • sed -i
  • A
  • \$to = ".*";$
  • B
  • \$to = example@example.com;
  • G
  • PATH
  • ```
  • * A means "from"
  • * B means "to"
  • * G means "global"
  • Since `sed` doesn't work this way, how could I achieve a similar syntax in the shell? Perhaps by using Python? Perl? Something else?
#2: Post edited by (deleted user) · 2021-09-19T11:29:14Z (about 3 years ago)
  • substituting text in a sed like manner but with a richer format
  • Substituting text in a sed like manner but with a richer format
#1: Initial revision by (deleted user) · 2021-09-19T11:28:52Z (about 3 years ago)
substituting text in a sed like manner but with a richer format
I have the following problems working with `sed`:

* It doesn't allow multiline operations (thus, no indentations, no nesting)
* It is generally obligatory to wrap entire commands in quote marks (`sed "SED_COMMAND"` FILE) even if the command itself contains quote marks

Without these problems I could format a long liner such as `sed -i "s/\$to = ".*";$/\$to = example@example.com;/g" PATH` as something like this pseudocode:

```shell
sed -i
    A
        \$to = ".*";$
    B
        \$to = example@example.com;
    G
PATH
```

* A means "from"
* B means "to"
* G means "global"

Since `sed` doesn't work this way, how could I achieve a similar code in the shell? Perhaps by using Python? Perl? Something else?