script

Shell Tricks

Coding in sh or bash can be challenging. Here are some tricks I've learned over the years

Extracting fields from lists

I have a list of items in $LIST; each item is separated from each other item by a comma, and individual items may contain spaces.

~ $ LIST="abc,def ghi,jkl"
~ $ echo [$LIST]
[abc,def ghi,jkl]

System Management: 
Articles: 

Pet Peeves: run-parts(8), asynchronous execution, and logging

I run Slackware on two of my systems. I have always admired Slackware's simplicity and honesty. Some people accuse it of being overly complex, but I've found that what others see as complexity, I see as the ability to control and fine-tune. Other distributions may be great for those who are looking for a Unix system with a Microsoft feel, but I prefer my OS to not hide it's controls, to not tell me that, for my own good, it won't do what I want it to do.

Slackware's run-parts(8) is one of those simple tools that works well. Built from a simple /bin/sh script, and using basic Linux tools, Slackware's run-parts does the basic work of "batch" processing for cron. But, this simplicity has it's price; target scripts are run synchronously, one after the other. If one get's stuck, the remainder can't run. And, there's no easy way to determine if a script has got "stuck"; there's no conveniently accessable logging of the start or termination of each script, nor is there any consistent way to gather messages from the scripts into one place.

And, so, my pet peeve: run-parts(8) doesn't do everything that I need in a batch processor. So, I went and built my own add-on solution.

System Management: 
Subscribe to RSS - script