On Wed, 21 Dec 2022 at 04:18, Lee wrote:
> On 12/20/22, David wrote:
> > $ echo -e '100:CD001\nXXX\n200:CD001' | awk 'BEGIN { FS=":" ; done=0 }
> > /CD001/ && done==0 { print $1 - 50 ; done=1 }'
> > 50
>
> You can do it without flags:
>
> $ echo -e '100:CD001\nXXX\n200:CD001' | awk -F: '/CD001/
On 12/20/22, David wrote:
> On Tue, 20 Dec 2022 at 22:04, David wrote:
>> On Tue, 20 Dec 2022 at 22:02, David wrote:
>
>> > $ echo -e '100:CD001\n200:CD001' | awk 'BEGIN { FS=":" } /CD001/ &&
>> > NR==1 { print $1 - 50 }'
>> > 50
>>
>> Oops, my mistake, that's not the solution. Give me another m
> Not that that is always important. But I just commented today
> because so often 'awk' is ignored as if its only capability is 'print $1'
> when in fact it is actually very powerful but neglected.
FWIW, `sed` can also do that job. Tho the subtraction part would take
a lot more work (`sed` does
On Tue, 20 Dec 2022 at 22:04, David wrote:
> On Tue, 20 Dec 2022 at 22:02, David wrote:
> > $ echo -e '100:CD001\n200:CD001' | awk 'BEGIN { FS=":" } /CD001/ &&
> > NR==1 { print $1 - 50 }'
> > 50
>
> Oops, my mistake, that's not the solution. Give me another minute and I
> will post a better one
Hi,
The Wanderer wrote:
> With the '-o' option, grep prints only the parts of the line that were
> matched - but the plural here is very relevant. If that guess is
> correct, then the "line" in question has *four* occurrences, so grep
> prints them all - each on a separate line of output.
The man
On Tue, 20 Dec 2022 at 22:02, David wrote:
> $ echo -e '100:CD001\n200:CD001' | awk 'BEGIN { FS=":" } /CD001/ &&
> NR==1 { print $1 - 50 }'
> 50
Oops, my mistake, that's not the solution. Give me another minute and I
will post a better one one.
On Tue, 20 Dec 2022 at 21:53, The Wanderer wrote:
> On 2022-12-20 at 05:37, David wrote:
> > On Tue, 20 Dec 2022 at 21:10, The Wanderer wrote:
> >> On 2022-12-20 at 02:51, Thomas Schmitt wrote:
> >>> This contradicts the promises of man grep about option -m.
> >> It does seem to, at least at a
On 2022-12-20 at 05:37, David wrote:
> On Tue, 20 Dec 2022 at 21:10, The Wanderer
> wrote:
>
>> On 2022-12-20 at 02:51, Thomas Schmitt wrote:
>>> This contradicts the promises of man grep about option -m.
>>
>> It does seem to, at least at a glance - but I think I've figured
>> out what's going
On Tue, 20 Dec 2022 at 21:10, The Wanderer wrote:
> On 2022-12-20 at 02:51, Thomas Schmitt wrote:
> >>> offst=$( expr \
> >>> $( grep -a -o -b -m 1 CD001 cdimage.iso \
> >>> | sed -e 's/:/ /' \
> >>> | awk '{ print $1 }' ) - 32769 )
> >
> > The Wande
On 2022-12-20 at 02:51, Thomas Schmitt wrote:
> Hi,
>
> i wrote:
>>> To obtain the offset of the first occurence of "CD001", do
>>>
>>> offst=$( expr \
>>> $( grep -a -o -b -m 1 CD001 cdimage.iso \
>>> | sed -e 's/:/ /' \
>>> | awk '{ print $1 }' )
10 matches
Mail list logo