Thursday, May 24, 2012

Jump to column in vi

You can jump to a line in vi with <line number>G

To jump to a column on the current line, use <column number>| (pipe character)

Friday, May 11, 2012

Add line after match using ex

This little script is to append a line to a file after a text match, using ex.

This particular one is for /usr/local/etc/sudoers to add a 5 minute timeout to the root sudo.

#!/bin/bash FILE=$1 cp -p $FILE $FILE.old ex $FILE <<EOT /^User_Alias.*UNIX.*wheel a Defaults:UNIX timestamp_timeout=5 . x! EOT