|
|
Another approach to working with "awk"A reader writes in with the following note:
I've just picked up your book Wicked Cool Shell Scripts, and there are a lot of nifty things in it. I too have accumulated a lot of things generally in small scripts or more frequently in bourne/bash functions. I was particularly tickled to see a lot of very similar code, one such that jumped out at me was your gmk function in one script (I called mine kmg).
You're right, this is a better approach to the problem, but you're not solving the same problem I am. :-)
What I'm getting is the last field if and only if it's prefaced by a space, whereas you're ignoring the leading space and looking just to see if the last field matches "$1". Where might this differ? When the output is a single word on a line by itself: with your conditional it could match, whereas with mine it couldn't. Nonetheless, I am happy to hear about smarter and more logical ways to solve problems that I talk about in my book, so please do feel free to send any further thoughts in!
Related Shell Script Programming articles:
✔ Secretly capture screenshots on my Mac?
When I used to work on a Linux system, there was a utility we had that would let me take screen captures every...
✔ Parsing "id" strings in a Shell Script?Hello Dave. I need a Bash shell script that creates a directories with the group names automatically when user logs in to the...
✔ Copy and Paste from the Mac OS X Command Line?I am constantly running commands in Terminal.app on my MacBook and then copying and pasting the results into email messages or documents. Yes,...
✔ Script to test line lengths for Twitter compatibility?I've been tasked with writing a series of tweets for a Black Friday marketing campaign and am finding it a bit tricky because...
✔ Shell script to convert lowercase to title case?As part of a project I'm working on, I find myself deep in a Linux shell script, needing to have a subroutine that...
Let's stay in touch!
Sign up for my weekly AskDaveTaylor Newsletter and you'll receive even more tech and gadget help
right to your inbox, along with exclusive news and industry updates. It's good stuff. I promise!
Categorized:
Shell Script Programming
(Article 3729,
Written by Dave Taylor)
Tagged: Previous: Where's this NotePad application? Next: What's Acceptable Search Engine "Spam" Technique? Reader Comments To Date:
Rather amazingly, there are no comments on this article yet.
I do have a comment, now that you mention it!Check This Out Too... |
Recent Entries
Look for Answers
Recommended
All Our Categories
Apple iPad Help
Articles and Reviews Auctions and Online Shopping Blogs and Blogging Building Web Site Traffic Business and Management Computer and Internet Basics d) None of the Above Facebook Help Google Gmail Help Google Plus Help HTML, JavaScript and Web Site Programming Industry News and Trade Shows iPhone and Cell Phone Help iPod, Sony PSP and MP3 Player Help Kindle Fire Help Mac OS X Help Pay Per Click (PPC) Advertising Pinterest Help Search Engine Optimization (SEO) Shell Script Programming Tech Support Video Help The Writing Business Twitter, LinkedIn and Social Network Help Unix and Linux Help Video Game Tips and Help Windows PC Help Find Me on Google+ ADT on G+ |