Tagged: bash

How to get a previous date in bash (linux) 0

How to get a previous date in bash (linux)

Simply put

date -d '1 day ago' +'%Y-%m-%d'
# For multiple days
date -d '7 days ago' +'%Y-%m-%d'

If you wish to place in a shell script:

RMDATE=$(date -d '7 days ago' +'%Y_%m_%d')

will place for example ‘2013-07-01’ in the RMDATE variable which of course you can use like

echo $RMDATE

 

How to find physical location of /dev/sd* drives in linux 0

How to find physical location of /dev/sd* drives in linux

I wrote a lil script to help out with this.. The syntax is as follows:

finddrive.py sda

How this works is by lighting up the corresponding drive on the front panel for about 3 seconds.

#!/bin/sh

cmd="dd if=/dev/$1 of=/dev/null"
seconds=3

echo "Check front panel for indicator light"
$cmd&

cmdpid=$!
sleep $seconds

if [ -d /proc/$cmdpid ]
then
  # echo "terminating program PID:$cmdpid"
  kill $cmdpid
fi

Credits:  Fabio’s Blog