'How to crop text after pattern in bash
If the text is
aaaa
bbbb
cccc
====
dddd
I want dddd as the result
If the text is
aaaa
====
bbbb
cccc
dddd
I want
bbbb
cccc
dddd
as the result.
I'm trying something like awk '{print $1}' | sed '/.*\n=*$/d' but it seems like sed can only delete a line.
Solution 1:[1]
You can try something like
n=$(grep -n "^=*$" $1 | awk -F: '{print $1}')
let n+=1
tail +$n $1
Solution 2:[2]
You can indicate a range of lines, e.g. from line 1 to the line containing the pattern:
sed '1,/====/d'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Yuri Ginsburg |
| Solution 2 | Beta |
