Datemath: a simple date calculator script

6 06 2009

datemath is a script for some simple math operations on dates in bash.

scakko@link:~/bin$ date
Sat Jun 6 01:54:53 CEST 2009
scakko@link:~/bin$ ./datemath +1D
Sun Jun 07 2009
scakko@link:~/bin$ ./datemath -1W
Sat May 30 2009
scakko@link:~/bin$ ./datemath +1M
Mon Jul 06 2009
scakko@link:~/bin$ ./datemath -1Y
Fri Jun 06 2008





Gapless Flac CD Ripping

11 05 2009

Install ABCDE (A Better CD Encoder)

sudo apt-get install abcde

insert the CD and run the following command

abcde -d /media/cdrom -1 -M -o flac

to obtain the rip.

Here are the meanings of every single option used in the previous command:

  • “-d /media/cdrom” stands for rip from /media/cdrom device
  • “-1″ stands for single file
  • “-M” stands for generate cue file
  • “-o flac” stands for encode output in flac format




Bash Script Parameters Number Check

31 03 2009

A code snippet for the parameters number checking in bash scripting

#!/bin/bash
 
ARGS=2
E_BADARGS=65
 
if [ $# -ne "$ARGS" ]
then
echo "Usage: `basename $0` <arg1> <arg2>"
exit $E_BADARGS
fi
 
ARG1=$1
ARG2=$2
 
command $ARG1 $ARG2
 
exit 0

it checks if parameter numbers isĀ  equal to ARGS, executing the command if true and exiting from script with error code 65 (Wrong Parameter Numbers) otherwise.