Adding a -p option to touch

I’ve sometimes wished that the UNIX touch command had the same -p option as mkdir. With a little bit of scripting, it can:

#!/bin/sh

mkdir=”/bin/mkdir”
touch=”/usr/bin/touch”

for arg in $*; do
if [ "$arg" = "-p" ]; then
opt_p=true
continue
. . . → Read More: Adding a -p option to touch

Useful tip on how to make bash check the window size between commands

Here’s a useful tip on how to make bash check the window size between commands.

shopt . . . → Read More: Useful tip on how to make bash check the window size between commands

Su su sudo: oh no

The other day I wanted to enable IP forwarding on my Linux box (so that it could forward packets from a tun virtual interface being used by VTun to the physical interface connected to my home network).

I looked up it up and it turns out that it’s a simple setting in a file in the /proc . . . → Read More: Su su sudo: oh no

Blast from the past: Sniglets

I’m reminded today of Sniglets. I grew up in the 1980s watching lots of HBO, so Rich Hall’s little segments from Not Necessarily the News occupy a special place in some dark corner of my cerebrum. I can still remember to this day:

flen – the yucky stuff that accumulates under the cap of a ketchup bottle.
accello-yellow . . . → Read More: Blast from the past: Sniglets

Having a bash with bash

Let’s say we want to write a command that allows you to take the output of the previous command and stick it in your editor so you can page through it, save it, email it, etc.

One way to do it is with bash’s “process substitution” feature. Try this:

$ ls -l
$ cat <($(tail -1 $HISTFILE)) | vim . . . → Read More: Having a bash with bash

Stupid bash trick of the day

function _globdo
{
local arg=”$1″
local dir=$(dirname $arg)
local base=$(basename $arg)
shift
find $dir -name $base -exec “$@” {} \;
set +f
}

alias globdo=’set -f; _globdo’

The function/alias combo is get around automatic globbing and make it possible to specify glob . . . → Read More: Stupid bash trick of the day

“recd” on sourceforge

Brian took my cd bash function hack, made a whole bunch of improvements, and created a Sourceforge project for it:

recd . . . → Read More: “recd” on sourceforge