Electricmonk

Ferry Boender

Programmer, DevOpper, Open Source enthusiast.

Blog

Category: shell scripting

Read the POSIX standard

Stop reading your local manual pages when programming/scripting stuff, and use the POSIX standard instead: Online POSIX 2008 (EEE Std 1003.1-2008) standard There are four main parts: The Base Definitions (XBD): The basics of a POSIX-compliant system. The System Interfaces (XSH): What POSIX-compliant systems offer to programs. I.e. programming in C (stdlib) The Shell & […]

Excluding results of a ‘find’ command (inverting tests)

In kind of a follow up to my previous post on using find and sed to search and replace multiple files, I found out something else. I needed to find and replace something in every file, except for any files which had “.svn” in them. After struggling for a few fruitless minutes with -regex, I […]

Linux search and replace

I always kept a small Python script around for searching and replacing in Linux. Turns out that GNU sed has an inline edit mode which I didn’t know about: -i[SUFFIX], –in-place[=SUFFIX] edit files in place (makes backup if extension supplied) This makes searching and replacing in files as simple as: find . -name “*.txt” -print0 […]

chkrootkit false positives filtering

Chkrootkit is a tool that searches for rootkits, trojans and other signs of break-ins on your system. Like most security scanners, it sometimes generates false positives. Chkrootkit doesn’t have a native way to filter those out. From the FAQ: [Q:] chkrootkit is reporting some files and dirs as suspicious: `.packlist’, `.cvsignore’, etc. These are clearly […]

Floating point stuff in Bash

Shell scripting is powerful, but unfortunatelly it gets less easy if you want to perform floating point calculations in it. There’s expr, but it only handles integers: [todsah@jib]~$ echo `expr 0.1 + 0.1` expr: non-numeric argument If you wish to perform floating point calculations in shell scripts, you can use the bc tool: “bc – […]

More XML Commandline unix tools

A little while ago I reported on a little XML toolset called XMLStarlet. XMLStartlet provided a bunch of commandline tools for reading and converting XML files from the commandline. Usefull in scripts. However, it uses a pretty complex interfacing. For instance, you’ll have to know XPath to easily select a particular piece of XML to […]

XML commandline toolset

Those who are familiar with Unix commandline tools like grep, sed and cut will know about the enormous power they provide. They make it a breeze to mangle, transform and retrieve information in and from text files. Unfortunately, they’re mostly dependant on row and column based information. That is, they expect each line in a […]

The text of all posts on this blog, unless specificly mentioned otherwise, are licensed under this license.