Re: [PLUG] Interest in high availability clustering talk?
On 2/14/24 12:44, Michael Dexter wrote: On 2/14/24 12:04 AM, Russell Senior wrote: I have a talk idea. Or possibly two ideas. If no one pre-empts me, I'll do March. Do tell! I have a vaguely clever network relay via an AWS instance (maybe moving to linode soonish) to serve my self-hosted email server. It involves an OpenVPN tunnel, some iptables rules and some source-routing. It isn't the only way or even necessarily the generally best way to do it, but it is *a* way and moreover, it is my way and it has some features that I like. That's probably isn't enough to fill an hour, so I thought I'd pair that with some show-and-tell regarding my DDS and QIC tape recovery project from a couple months ago. -- Russell Senior russ...@pdxlinux.org
Re: [PLUG] gawk: a pattern that separates two similar strings
With this input in the file /tmp/input2 This is the header line from the input file 410 Auto Wrecking,410 Auto Wrecking,So3011780,Inactive,Industrial SW GP,27865 Sr 410 E,Buckley,Pierce,98321,ROW_1 410 Auto Wrecking,410 Auto Wrecking,WAR011780,Active,Industrial SW GP,27865 Sr 410 E,Buckley,Pierce,98321,ROW_2 410 Auto Wrecking,410 Auto Wrecking,So3011780,Inactive,Industrial SW GP,27865 Sr 410 E,Buckley,Pierce,98321,ROW_3 410 Auto Wrecking,410 Auto Wrecking,WAR011780,Active,Industrial SW GP,27865 Sr 410 E,Buckley,Pierce,98321,ROW_4 Using this script in the file dogawk: BEGIN { FS = OFS = "," } NR ~ /1/ { print $0 } $4 == "Inactive" { next } $4 == "Active" { print $0 } and with this command on bash: gawk -f dogawk /tmp/input2 I get this output, with the header row and the Active rows, only: This is the header line from the input file 410 Auto Wrecking,410 Auto Wrecking,WAR011780,Active,Industrial SW GP,27865 Sr 410 E,Buckley,Pierce,98321,ROW_2 410 Auto Wrecking,410 Auto Wrecking,WAR011780,Active,Industrial SW GP,27865 Sr 410 E,Buckley,Pierce,98321,ROW_4 For completeness, gawk --version outputs: GNU Awk 5.1.1, API: 3.1 (GNU MPFR 4.1.1-p1, GNU MP 6.2.1) Copyright (C) 1989, 1991-2021 Free Software Foundation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. gawk output ends If I instrument your script with printf's, like this: BEGIN { FS = OFS = "," } NR ~ /1/ { printf "I am executing the NR line "; print $0 } $4 == "Inactive" { printf "I am executing the next branch\n"; next } $4 == "Active" { printf "I think I am on an Active line "; print $0 } and I run it again with the /tmp/input2 file, I get: I am executing the NR line This is the header line from the input file I am executing the next branch I think I am on an Active line 410 Auto Wrecking,410 Auto Wrecking,WAR011780,Active,Industrial SW GP,27865 Sr 410 E,Buckley,Pierce,98321,ROW_2 I am executing the next branch I think I am on an Active line 410 Auto Wrecking,410 Auto Wrecking,WAR011780,Active,Industrial SW GP,27865 Sr 410 E,Buckley,Pierce,98321,ROW_4 Suggestion: try inserting printf's to see what line of your script is outputting what. --Seth
Re: [PLUG] gawk: a pattern that separates two similar strings
On Wed, 14 Feb 2024, wes wrote: you can exclude lines containing a given value with grep. grep -v Inactive input.txt this could cause problems if one of the other fields contained the word Inactive but it's a start. wes, That's a good idea. As I just responded to Reid, without printing the first record (the column headers) the script works. That doesn't make sense to me. Thanks, Rich
Re: [PLUG] gawk: a pattern that separates two similar strings
On Wed, 14 Feb 2024, Reid wrote: Okay, that's not my experience. Using your script and adding a row-number field to the end of each line: $ cat /tmp/tmp.txt 410 Auto Wrecking,410 Auto Wrecking,So3011780,Inactive,Industrial SW GP,27865 Sr 410 E,Buckley,Pierce,98321,ROW_1 410 Auto Wrecking,410 Auto Wrecking,WAR011780,Active,Industrial SW GP,27865 Sr 410 E,Buckley,Pierce,98321,ROW_2 410 Auto Wrecking,410 Auto Wrecking,So3011780,Inactive,Industrial SW GP,27865 Sr 410 E,Buckley,Pierce,98321,ROW_3 410 Auto Wrecking,410 Auto Wrecking,WAR011780,Active,Industrial SW GP,27865 Sr 410 E,Buckley,Pierce,98321,ROW_4 $ gawk -f /tmp/tmp.gawk /tmp/tmp.txt 410 Auto Wrecking,410 Auto Wrecking,So3011780,Inactive,Industrial SW GP,27865 Sr 410 E,Buckley,Pierce,98321,ROW_1 410 Auto Wrecking,410 Auto Wrecking,WAR011780,Active,Industrial SW GP,27865 Sr 410 E,Buckley,Pierce,98321,ROW_2 410 Auto Wrecking,410 Auto Wrecking,WAR011780,Active,Industrial SW GP,27865 Sr 410 E,Buckley,Pierce,98321,ROW_4 Note that the first "Inactive" line is printed because it's the first record. The second "Inactive" line is not printed. Reid, Removing the subscr() and using this script: BEGIN { FS = OFS = "," } # NR ~ /1/ { print $0 } $4 == "Inactive" { next } $4 == "Active" { print $0 } it now works; only Active rows are returned. But, when I uncomment the first statement to print the header row I also get the inactive rows. Why might this be? Thanks, Rich
Re: [PLUG] gawk: a pattern that separates two similar strings
On Wed, Feb 14, 2024 at 10:47 AM Rich Shepard wrote: > I've downloaded a data file where the permit type can be Active, Inactive, > or Draft. > > Removing all Draft records was easy. Removing all Inactive records has so > far escaped my gawk (and LO Calc) efforts because Inactive contains the > substring 'active'. > > My script: > BEGIN { FS = OFS = "," } >NR ~ /1/ { print $0 } >$4 == "Inactive" { next } >$4 == "Active" { print $0 } > > I've also tried with matching: >$4 ~ /Inactive/ { next } >$4 ~ /Active/ { print $0 } > > And, of course, specifying only field 4 containing Active also fails. > > My AWK books and web searches haven't taught me how to write a pattern that > matches only 'active' and not 'inactive.' > > Would the substr() function do the job? E.g,, substr(Active,1,6) > > Here are two sample records: > 410 Auto Wrecking,410 Auto Wrecking,So3011780,Inactive,Industrial SW > GP,27865 Sr 410 E,Buckley,Pierce,98321 > 410 Auto Wrecking,410 Auto Wrecking,WAR011780,Active,Industrial SW > GP,27865 Sr 410 E,Buckley,Pierce,98321 > > you can exclude lines containing a given value with grep. grep -v Inactive input.txt this could cause problems if one of the other fields contained the word Inactive but it's a start. -wes
Re: [PLUG] Interest in high availability clustering talk?
On 2/14/24 12:04 AM, Russell Senior wrote: I have a talk idea. Or possibly two ideas. If no one pre-empts me, I'll do March. Do tell! Michael
Re: [PLUG] gawk: a pattern that separates two similar strings
On Wednesday, February 14th, 2024 at 11:39 AM, Rich Shepard wrote: > On Wed, 14 Feb 2024, Reid wrote: > > > The `NR ~ /1/` line is causing the first line to be printed, regardless of > > its contents. > > > Reid, > > With the full data set that's the column header row so I left it in the > script because I'm working with the full set. > > However, commenting it out I still get the Inactive records (and the Draft > ones because I've not yet removed those.) Okay, that's not my experience. Using your script and adding a row-number field to the end of each line: $ cat /tmp/tmp.txt 410 Auto Wrecking,410 Auto Wrecking,So3011780,Inactive,Industrial SW GP,27865 Sr 410 E,Buckley,Pierce,98321,ROW_1 410 Auto Wrecking,410 Auto Wrecking,WAR011780,Active,Industrial SW GP,27865 Sr 410 E,Buckley,Pierce,98321,ROW_2 410 Auto Wrecking,410 Auto Wrecking,So3011780,Inactive,Industrial SW GP,27865 Sr 410 E,Buckley,Pierce,98321,ROW_3 410 Auto Wrecking,410 Auto Wrecking,WAR011780,Active,Industrial SW GP,27865 Sr 410 E,Buckley,Pierce,98321,ROW_4 $ gawk -f /tmp/tmp.gawk /tmp/tmp.txt 410 Auto Wrecking,410 Auto Wrecking,So3011780,Inactive,Industrial SW GP,27865 Sr 410 E,Buckley,Pierce,98321,ROW_1 410 Auto Wrecking,410 Auto Wrecking,WAR011780,Active,Industrial SW GP,27865 Sr 410 E,Buckley,Pierce,98321,ROW_2 410 Auto Wrecking,410 Auto Wrecking,WAR011780,Active,Industrial SW GP,27865 Sr 410 E,Buckley,Pierce,98321,ROW_4 Note that the first "Inactive" line is printed because it's the first record. The second "Inactive" line is not printed. > > Thanks, > > Rich Regards, Reid Wahl (he/him) Sent with Proton Mail secure email.
Re: [PLUG] gawk: a pattern that separates two similar strings
On Wed, 14 Feb 2024, Reid wrote: The `NR ~ /1/` line is causing the first line to be printed, regardless of its contents. Reid, With the full data set that's the column header row so I left it in the script because I'm working with the full set. However, commenting it out I still get the Inactive records (and the Draft ones because I've not yet removed those.) Thanks, Rich
Re: [PLUG] gawk: a pattern that separates two similar strings
Regards, Reid Wahl (he/him) Sent with Proton Mail secure email. On Wednesday, February 14th, 2024 at 10:47 AM, Rich Shepard wrote: > I've downloaded a data file where the permit type can be Active, Inactive, > or Draft. > > Removing all Draft records was easy. Removing all Inactive records has so > far escaped my gawk (and LO Calc) efforts because Inactive contains the > substring 'active'. > > My script: > BEGIN { FS = OFS = "," } > NR ~ /1/ { print $0 } > $4 == "Inactive" { next } > $4 == "Active" { print $0 } > > I've also tried with matching: > $4 ~ /Inactive/ { next } > $4 ~ /Active/ { print $0 } > > And, of course, specifying only field 4 containing Active also fails. > > My AWK books and web searches haven't taught me how to write a pattern that > matches only 'active' and not 'inactive.' > > Would the substr() function do the job? E.g,, substr(Active,1,6) > > Here are two sample records: > 410 Auto Wrecking,410 Auto Wrecking,So3011780,Inactive,Industrial SW GP,27865 > Sr 410 E,Buckley,Pierce,98321 > 410 Auto Wrecking,410 Auto Wrecking,WAR011780,Active,Industrial SW GP,27865 > Sr 410 E,Buckley,Pierce,98321 > > TIA, > > Rich The `NR ~ /1/` line is causing the first line to be printed, regardless of its contents.
Re: [PLUG] gawk: a pattern that separates two similar strings
On Wed, 14 Feb 2024, Rich Shepard wrote: Would the substr() function do the job? E.g,, substr(Active,1,6) Apparently not: BEGIN { FS = OFS = "," } NR ~ /1/ { print $0 } $4 == substr(Active,1,6) { print $0 } still has Inactive in the output. Sigh, Rich
[PLUG] gawk: a pattern that separates two similar strings
I've downloaded a data file where the permit type can be Active, Inactive, or Draft. Removing all Draft records was easy. Removing all Inactive records has so far escaped my gawk (and LO Calc) efforts because Inactive contains the substring 'active'. My script: BEGIN { FS = OFS = "," } NR ~ /1/ { print $0 } $4 == "Inactive" { next } $4 == "Active" { print $0 } I've also tried with matching: $4 ~ /Inactive/ { next } $4 ~ /Active/ { print $0 } And, of course, specifying only field 4 containing Active also fails. My AWK books and web searches haven't taught me how to write a pattern that matches only 'active' and not 'inactive.' Would the substr() function do the job? E.g,, substr(Active,1,6) Here are two sample records: 410 Auto Wrecking,410 Auto Wrecking,So3011780,Inactive,Industrial SW GP,27865 Sr 410 E,Buckley,Pierce,98321 410 Auto Wrecking,410 Auto Wrecking,WAR011780,Active,Industrial SW GP,27865 Sr 410 E,Buckley,Pierce,98321 TIA, Rich
Re: [PLUG] Interest in high availability clustering talk?
I have a talk idea. Or possibly two ideas. If no one pre-empts me, I'll do March. -- Russell Senior PLUG Volunteer russ...@pdxlinux.org On 2/13/24 22:17, Michael Dexter wrote: Russell, You have someone also wanting to skip March for April Michael On 2/13/24 9:53 PM, Reid wrote: On Tuesday, January 30th, 2024 at 3:26 PM, Michael Dexter wrote: Reid, Sounds great! Does March work for you? Whoops, I thought I responded. It's going to have to wait until at least April, sorry. I wanted to put out a feeler to gauge interest. Michael Dexter PLUG Volunteer On 1/29/24 10:46 PM, Reid wrote: Would there be any interest in a talk, demo, or workshop/troubleshooting session on high availability clustering? The format and content would be flexible depending on what people want and what's relevant to you all. I'm a maintainer of the open source Pacemaker cluster resource manager, and I worked in backline support for it for a few years prior. https://clusterlabs.org/pacemaker/ Regards, Reid Wahl (he/him) Sent with Proton Mail secure email.