Linux

A EXIF dater script

The script below will take a filename eg: DSCN0001.JPG, extract the “Image Created” metadata and rename the original file to something like 2006-03-23_DSCN00001.JPG and it will do it automatically for you. #! /bin/shfunction usage() {if [ $# -ne 1 ]; then    echo “ExifDater – version 0.1 – March 23 2006”    echo “El-Lotso ”…

Read More
Linux

Strip comments from config files

This is at short script to strip/remove comments from config files #!/bin/bash # Code to cat a config file removing all comments and blank lines. grep -vh ‘^[[:space:]]*#’ “$@” | grep -v ‘^$’ Usage: ./confcat.sh /etc/make.conf Alternativ is to use sed cat filename | sed -e ‘s/#.*//;/^\s*$/d’ “$@” This also strips comments at the end…

Read More
Security

Tunneling ports with SSH

Using -L on the command line with SSh will bind a remote port to a local one. For instance, if you wanted to tunnel the port for a remote desktop (usually 5901) to a local machine, you would type the following ssh -L 5901:localhost:5901 remote_ip You could then access your remote desktop by connecting your…

Read More
Scripting

Ten Cool Coreutils Commands

While a few commands, such as ‘cd’ are built directly into bash; many of the most important commands come from coreutils, a GNU package containing over a hundred commands. Some are the well known commands such as ‘ls’, ‘mv’ and ‘cat’. While there are some more obscure ones that are not always discovered because there…

Read More
Linux

Root Check

Sometime it is useful to determine if a script is being run as root or not. A simple check can be performed at the start of a script before anything important is done. The bit of code below will do this. # Check the script is being run by root if [ “$(id -u)” !=…

Read More