[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Rewriting file from bash
From: |
Julius Hamilton |
Subject: |
Rewriting file from bash |
Date: |
Sun, 3 Oct 2021 17:16:04 +0200 |
Hey,
How could I print the nth region of text of a file that is between blank
newline regions, at the command line? So for example:
file.txt:
line1
line2
line3
line4
$ region[2]
would return
line2
line3
I presume this would be with grep, sed and/or awk.
How could I then write a replacement for that region, from the command line
(i.e. not using Vim or something)? Something like:
$ region [2] “this is the replacement line”
Thank you very much,
Julius
- Rewriting file from bash,
Julius Hamilton <=