Mar 17 2016
When using sed (Stream EDitor) in a shell script to match or strip out certain strings of characters, keep in mind that character usage in the regular expressions doesn't work the same. For example, running the following command manually on the command line works properly, but does not do what you'd expect inside a shell script:
That command is supposed to find all of the tags in an HTML document and substitute for them nothing (i.e., erasing them from the file). It works properly if run manually, but inside a shellscript you're not getting a true backslash to escape the forward slash. To put it another way, as far as sed is concerned, you're giving it the following command, which won't do what you want it to:
That puts an extra forward slash in the regular expression, which causes it to ABEND. The actual command that you should put in the shell script is this:
It is possible to convert a Unix time_t timestamp into a human-readable format using the Unix date utility. On a Linux machine, you do it like this:
date -d "1970-01-01 UTC time_t value here seconds"
That's a literal command - 'seconds' is the word 'seconds', and is a command to GNU date that tells it that the number immediately before it is in seconds, and not data in another format.
Your output will be a more easily understood date and time.
When debugging, eliminate as many variables as you can. If you have to turn off or comment out major chunks of code to turn off a single function performed by the programme, then do so. Turn things back on one at a time. You want to minimise the number of variables that you have to deal with when you're trying to isolate the parts that are not behaving the way you want them to.
You can perform regular expression matching in shell scripts without external tools, but it's not as pretty or as advanced. Check out the expr command (farther down on the page).
You will always discover three cosmetic bugs in the in-house software they've just installed on a public system thirty seconds after copying it into place. These bugs don't harm functionality any, but will cause a firestorm of support tickets because they make the output look ugly.
Paradoxically, bugs that actually do break functionality only bring responses of the form "Well, it's not important, so fix it when you get a chance.
If you're running a Linux machine under X or x.org in dual-headed mode but you're not using the Xinerama function, xscreensaver will display two different screensavers, one on either screen. You still get the huge desktop spanning both monitors, though.
You know you're in trouble when your software development project's release numbers aren't of the form "v1.0" or "v1.1" but are instead time_t values.