[CDBUG-talk] Weird scripting question
Jaime
jaime at snowmoon.com
Sat Feb 11 16:45:29 EST 2017
Justin: I would typically use Perl for this sort of thing, too. It's just
that in this case, the process was originally so simple that I implemented
it in a bash script that was a quick SFTP get command, an "awk | sed | sed
| grep -v" pipe-chain, and an SFTP put command. I was (very
coincidentally) reading about awk lately when this issue popped up. So I
hoped to use this as a learning experience. I was starting to debate
rewriting the entire thing in Perl, though.
The good news is that I think I it figured out in awk. I just needed a
perspective shift, which I achieved thanks to all the feedback here and
elsewhere. If pseudocode, this is what I needed to do:
if (grade_level not null) {
# This is a student
$primary_key = student_ID
} else {
# This is an employee
$primary_key = employee_ID# && first_letter_of_school_name
}
print "$primary_key, $2, $3, $4"
Once I realized this, it was easy to add a few lines to the existing awk
script using "if" and "substr()". It appears to be working as desired
now. When I return to work on Monday, I'll check for side-effects (since
I'm altering a live system) and then deploy.
Thanks a bunch for the thought provoking replies!
Jaime
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nycbug.org/pipermail/cdbug-talk/attachments/20170211/eec2375c/attachment.html>
More information about the CDBUG-talk
mailing list