Reputation: 3713
Using sed, I'm trying to remove everything before a defined pattern and everything after a different one.
head
and tail
don't quite cut it because they just remove lines, not characters.
From:
0
0
0A
Z0
)
>
To:
A
Z
Upvotes: 0
Views: 150
Reputation: 36262
One way:
sed -ne '
/A/,/Z/ {
/A/ s/^[^A]*//;
/Z/ s/\(Z\).*$/\1/;
p;
}
' infile
Assuming infile
with content:
0
0
01234A56789
1
2
01234Z56789
)
>
Result will be:
A56789
1
2
01234Z
Upvotes: 1