greymd / teip

Masking tape to help commands "do one thing well"
MIT License
569 stars 19 forks source link

Select range of lines with regex like sed's /AAA/,/BBB/ #3

Closed greymd closed 2 years ago

greymd commented 4 years ago

sed, awk and perl support the range selection with regex.

$ seq 10 | sed -n '/4/,/8/p'
4
5
6
7
8

$ seq 10 | awk '/4/,/8/{ print $0}'
4
5
6
7
8

$ seq 10 | perl -nle 'print $_ if /4/../8/'
4
5
6
7
8

teip should have same feature. such as..

$ teip -B 'AAA' -E 'BBB'

Came from begin and end. But in that situation, -s option have to be enabled.

greymd commented 4 years ago

This is also good.

$ teip -R <begin_pat> <end_pat>
greymd commented 4 years ago

Just idea

teip -bg AAA -eg BBB
teip -b 0 -e 3
teip -b 0 -e +3
teip -b 0 -e '~3'
teip -b 0 -e '$'
greymd commented 2 years ago

This idea is no longer helpful. From v2.0.0, -e option can achieve it.

i.e

teip -e 'sed -n /AAA/,/BBB/='