From: superpollo on
mop2 ha scritto:
> On Sun, 10 Jan 2010 14:06:29 -0200, superpollo <utente(a)esempio.net> wrote:
>
>> still, i would use sed *after* i checked input in my script that uses
>> the sed script in turn (maybe using echo | grep).
>>
>
>
>
> $ p(){ [ "${1//[0-9]/}${2//[0-9]/}" ]&&echo only numbers >&2&&return
> 1;sed -n $1${2//$2/,$2}p;}

yea like this!

a veritable sed fan, alright?

btw (offtopic), are there troff/pic/eqn users down here?

bye
From: Ed Morton on
On 1/10/2010 10:42 AM, superpollo wrote:
> mop2 ha scritto:
>> On Sun, 10 Jan 2010 14:06:29 -0200, superpollo <utente(a)esempio.net>
>> wrote:
>>
>>> still, i would use sed *after* i checked input in my script that uses
>>> the sed script in turn (maybe using echo | grep).
>>>
>>
>>
>>
>> $ p(){ [ "${1//[0-9]/}${2//[0-9]/}" ]&&echo only numbers >&2&&return
>> 1;sed -n $1${2//$2/,$2}p;}
>
> yea like this!
>
> a veritable sed fan, alright?

That's not sed, it's shell, the sed part didn't change.

> btw (offtopic), are there troff/pic/eqn users down here?

There's a few of us around, but it's been a long, long time....

Ed.

From: mop2 on
On Sun, 10 Jan 2010 14:42:10 -0200, superpollo <utente(a)esempio.net> wrote:

> mop2 ha scritto:
>> On Sun, 10 Jan 2010 14:06:29 -0200, superpollo <utente(a)esempio.net> wrote:
>>
>>> still, i would use sed *after* i checked input in my script that uses
>>> the sed script in turn (maybe using echo | grep).
>>>
>>
>>
>>
>> $ p(){ [ "${1//[0-9]/}${2//[0-9]/}" ]&&echo only numbers >&2&&return
>> 1;sed -n $1${2//$2/,$2}p;}
>
> yea like this!
>
> a veritable sed fan, alright?

No, as Ed Morton said, that is just shell code before same sed command
The sed command is based on one of pks's suggestions

For very small files, an option using only shell resources may be enough,
and even faster, if sed is not already in disk's cache:

p(){
[ ! "$1" ]||[ "${1//[0-9]/}${2//[0-9]/}" ]&&echo need 2 numbers >&2&&return 1
x=0;z=$2;z=${z:=$1};while read;do x=$[x+1]
[ $x -ge $1 -a $x -le $z ]&&echo "$REPLY"
done
}

$ seq 9|p
need 1 or 2 numbers
$ seq 9|p 4
4
$ seq 9|p 4 6
4
5
6
$ seq 9|p 4 oops
need 1 or 2 numbers
$
From: Arcege on
On Jan 10, 11:42 am, superpollo <ute...(a)esempio.net> wrote:
> mop2 ha scritto:
>
> > On Sun, 10 Jan 2010 14:06:29 -0200, superpollo <ute...(a)esempio.net> wrote:
>
> >> still, i would use sed *after* i checked input in my script that uses
> >> the sed script in turn (maybe using echo | grep).
>
> > $ p(){ [ "${1//[0-9]/}${2//[0-9]/}" ]&&echo only numbers >&2&&return
> > 1;sed -n $1${2//$2/,$2}p;}
>
> yea like this!
>
> a veritable sed fan, alright?
>
> btw (offtopic), are there troff/pic/eqn users down here?
>
> bye

Yes, there are still some *roff/eqn users around. Never really used
pic much.

-Arcege