Re: grep: show matching line from pattern file

2022-06-04 Thread DdB
Hello, of course, there are different ways to solve this, i like the perl approach. Only since i myself am not all that familiar with the language, i'd like to add 2 pointers: (M)AWK scripting language can do similar things (read syslog once, loop over regular expressions and output anything you

Re: grep: show matching line from pattern file

2022-06-03 Thread Richard Hector
On 3/06/22 07:17, Greg Wooledge wrote: On Thu, Jun 02, 2022 at 03:12:23PM -0400, duh wrote: > > Jim Popovitch wrote on 28/05/2022 21:40: > > > I have a file of regex patterns and I use grep like so: > > > > > > ~$ grep -f patterns.txt /var/log/syslog > > > > > > What I'd like to get is

Re: Bash and the PS1 environment variable [was: grep: show matching line from pattern file]

2022-06-03 Thread David Christensen
On 6/2/22 22:50, Will Mengarini wrote: * David Christensen [22-06/02=Th 19:18 -0700]: [...] Now I can almost match your prompt -- there is a dash before 'bash': 2022-06-02 19:05:10 dpchrist@laalaa ~ $ PS1="\\h/${TTY#/dev/} \\s$SHLVL \\w \\A \$?\\\$" laalaa/pts/8 -bash1 ~ 19:08 0$ The dash

Re: Bash and the PS1 environment variable [was: grep: show matching line from pattern file]

2022-06-02 Thread Will Mengarini
* David Christensen [22-06/02=Th 19:18 -0700]: > [...] > Now I can almost match your prompt -- there is a dash before 'bash': > > 2022-06-02 19:05:10 dpchrist@laalaa ~ > $ PS1="\\h/${TTY#/dev/} \\s$SHLVL \\w \\A \$?\\\$" > laalaa/pts/8 -bash1 ~ 19:08 0$ > > The dash seems to be coming from the

Re: Bash and the PS1 environment variable [was: grep: show matching line from pattern file]

2022-06-02 Thread David Christensen
On 6/2/22 19:25, Greg Wooledge wrote: On Thu, Jun 02, 2022 at 06:01:11PM -0700, David Christensen wrote: This is my PS1. '\u' does not work on all of Debian, FreeBSD, Cygwin, and macOS, so the expansion of ${USER} is inserted between two string literals when .profile runs and sets PS1:

Re: Bash and the PS1 environment variable [was: grep: show matching line from pattern file]

2022-06-02 Thread Greg Wooledge
On Thu, Jun 02, 2022 at 06:01:11PM -0700, David Christensen wrote: > This is my PS1. '\u' does not work on all of Debian, FreeBSD, Cygwin, and > macOS, so the expansion of ${USER} is inserted between two string literals > when .profile runs and sets PS1: > > 2022-06-02 17:39:09 dpchrist@laalaa ~

Re: Bash and the PS1 environment variable [was: grep: show matching line from pattern file]

2022-06-02 Thread David Christensen
On 6/2/22 18:35, Will Mengarini wrote: * David Christensen [22-06/02=Th 18:01 -0700]: On 6/2/22 17:12, Will Mengarini wrote: * David Christensen [22-06/02=Th 15:50 -0700]: On 6/2/22 15:13, Will Mengarini wrote: In this transcript, the number before the prompt-ending '$' is $?:

Re: Bash and the PS1 environment variable [was: grep: show matching line from pattern file]

2022-06-02 Thread Will Mengarini
* David Christensen [22-06/02=Th 18:01 -0700]: >On 6/2/22 17:12, Will Mengarini wrote: >> * David Christensen [22-06/02=Th 15:50 -0700]: >>> On 6/2/22 15:13, Will Mengarini wrote: > In this transcript, the number before the prompt-ending '$' is $?:

Bash and the PS1 environment variable [was: grep: show matching line from pattern file]

2022-06-02 Thread David Christensen
On 6/2/22 17:12, Will Mengarini wrote: > * David Christensen [22-06/02=Thu 15:50 -0700]: >> On 6/2/22 15:13, Will Mengarini wrote: >>> In this transcript, the number before the prompt-ending '$' is $?: >>> >>> debian/pts/4 bash3 ~ 14:56 0$perl -e 'open

Re: grep: show matching line from pattern file

2022-06-02 Thread Will Mengarini
* David Christensen [22-06/02=Thu 15:50 -0700]: > On 6/2/22 15:13, Will Mengarini wrote: >> * Greg Wooledge [22-05/28=Sa 17:11 -0400]: >>> [...] >>> #!/usr/bin/perl >>> use strict; use warnings; >>> [...] >>> open PATS, ">> [...] >> >> You need "or die", not "|| die", because of precedence: what

Re: grep: show matching line from pattern file

2022-06-02 Thread David Christensen
On 6/2/22 15:13, Will Mengarini wrote: * Greg Wooledge [22-05/28=Sa 17:11 -0400]: [...] #!/usr/bin/perl use strict; use warnings; [...] open PATS, " You need "or die", not "|| die", because of precedence: what you coded checks whether " +1 That is a good explanation of a Perl fine point/

Re: grep: show matching line from pattern file

2022-06-02 Thread Will Mengarini
* Greg Wooledge [22-05/28=Sa 17:11 -0400]: > [...] > #!/usr/bin/perl > use strict; use warnings; > [...] > open PATS, " [...] You need "or die", not "|| die", because of precedence: what you coded checks whether " perl -le"print unpack '%C*',MENGARINI"

Re: grep: show matching line from pattern file

2022-06-02 Thread Greg Wooledge
On Thu, Jun 02, 2022 at 03:12:23PM -0400, duh wrote: > > > Jim Popovitch wrote on 28/05/2022 21:40: > > > > I have a file of regex patterns and I use grep like so: > > > > > > > > ~$ grep -f patterns.txt /var/log/syslog > > > > > > > > What I'd like to get is a listing of all lines,

Re: grep: show matching line from pattern file

2022-06-02 Thread duh
On 5/29/22 9:44 AM, David Wright wrote: On Sun 29 May 2022 at 15:02:35 (+0200), Jörg-Volker Peetz wrote: Jim Popovitch wrote on 28/05/2022 21:40: Not exactly Debian specific, but hoping that someone here can help. I have a file of regex patterns and I use grep like so: ~$ grep -f

Re: grep: show matching line from pattern file

2022-05-29 Thread Jim Popovitch
On Sat, 2022-05-28 at 17:11 -0400, Greg Wooledge wrote: > On Sat, May 28, 2022 at 04:02:39PM -0400, The Wanderer wrote: > > On 2022-05-28 at 15:40, Jim Popovitch wrote: > > > I have a file of regex patterns and I use grep like so: > > > > > >    ~$ grep -f patterns.txt /var/log/syslog > > > > >

Re: grep: show matching line from pattern file

2022-05-29 Thread David Wright
On Sun 29 May 2022 at 15:02:35 (+0200), Jörg-Volker Peetz wrote: > Jim Popovitch wrote on 28/05/2022 21:40: > > Not exactly Debian specific, but hoping that someone here can help. > > > > I have a file of regex patterns and I use grep like so: > > > > ~$ grep -f patterns.txt /var/log/syslog

Re: grep: show matching line from pattern file

2022-05-29 Thread Jörg-Volker Peetz
Jim Popovitch wrote on 28/05/2022 21:40: Not exactly Debian specific, but hoping that someone here can help. I have a file of regex patterns and I use grep like so: ~$ grep -f patterns.txt /var/log/syslog What I'd like to get is a listing of all lines, specifically the line numbers of the

Re: grep: show matching line from pattern file

2022-05-28 Thread The Wanderer
On 2022-05-28 at 17:11, Greg Wooledge wrote: > On Sat, May 28, 2022 at 04:02:39PM -0400, The Wanderer wrote: > >> On 2022-05-28 at 15:40, Jim Popovitch wrote: >> > I have a file of regex patterns and I use grep like so: >> > >> >~$ grep -f patterns.txt /var/log/syslog >> > >> > What I'd

Re: grep: show matching line from pattern file

2022-05-28 Thread Greg Wooledge
On Sat, May 28, 2022 at 04:02:39PM -0400, The Wanderer wrote: > On 2022-05-28 at 15:40, Jim Popovitch wrote: > > I have a file of regex patterns and I use grep like so: > > > >~$ grep -f patterns.txt /var/log/syslog > > > > What I'd like to get is a listing of all lines, specifically the

Re: grep: show matching line from pattern file

2022-05-28 Thread The Wanderer
On 2022-05-28 at 15:40, Jim Popovitch wrote: > Not exactly Debian specific, but hoping that someone here can help. > > I have a file of regex patterns and I use grep like so: > >~$ grep -f patterns.txt /var/log/syslog > > What I'd like to get is a listing of all lines, specifically the

grep: show matching line from pattern file

2022-05-28 Thread Jim Popovitch
Not exactly Debian specific, but hoping that someone here can help. I have a file of regex patterns and I use grep like so: ~$ grep -f patterns.txt /var/log/syslog What I'd like to get is a listing of all lines, specifically the line numbers of the regexps in patterns.txt, that match