User Tools

Site Tools


development:scripts:start

Scripts

Shell

How to "source" an environment for a command

$SHELL -c "( source env-of-cmd.sh ; $* )"

How to "daemonize" a script

if [ "x$1" != "x--" ]; then
    echo "restarting as daemon..."
    $0 -- &
    exit 0
fi
 
# stuff to do

Compare two directory listings (regarding names and size)

ls -lL <path/to/dir1> | sed -e 's/ [ ]*/ /g' | cut -d ' ' -f '5,9-' | sort -k 2 > dir1.lst
ls -lL <path/to/dir2> | sed -e 's/ [ ]*/ /g' | cut -d ' ' -f '5,9-' | sort -k 2 > dir2.lst
diff dir1.lst dir2.lst

SED

Squeeze multiple spaces to single

sed -e 's/ [ ]*/ /g'
development/scripts/start.txt · Last modified: 2016/01/04 11:46 (external edit)