Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Peter Cooperx http://www.petercooper.co.uk/

« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS 

See your most used shell commands

Found here.

history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -n | tail | sort -nr

Old Ensim backup scripts

backup

#!/bin/sh

echo $1
cd /home/virtual/$1/var/www
tar czfv /home/backups/$1.tar.gz cgi-bin html > /dev/null
chmod 777 /home/backups/$1.tar.gz
echo Backed up $1 to /home/backups/$1.tar.gz


backup-all

#!/bin/sh

rm -f /home/backups/old/*
mv /home/backups/*.gz /home/backups/old/
find -type l -maxdepth 1 -name '*.*' | xargs -n 1 basename | xargs -n 1 ./backup

Change file extensions with bash shell

To change all .htm files in a folder to .html files:

for f in *.htm; do mv $f `basename $f .htm`.html; done;

bash shell directory shortcuts

Go back to your previous directory:

cd -


Go to a new directory and push the current one onto a stack:

pushd /newdirectory


Pop a directory from the stack and go to it:

popd
« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS