Grep duplicate JSON keys

If you have large JSON files with application settings in, you need to be sure that the settings only appear once. Not a problem until you get to the stage of very large files, being edited by all sorts of people manually.

"setting_1" : "some value",
"setting_2" : "another value",
"setting_1" : "different again"

Run a script to check for duplicate key names:

grep -Po '"[a-z_0-9]+"[ ]*:' <filename> | uniq -d

The above will output the duplicated setting(s) if any, to the console. Tested on Ubuntu 12.04

Backup all SVN repos

If you need to backup your SVN repositories, then you can use this bash script to do so:

DATE=`date +"%Y-%m-%d"`
mkdir -p $BACKUP_DIR
for dir in `ls /var/svn/`; do
    svnadmin dump $RES_DIR | gzip > "${BACKUP_DIR}/${dir}.dump.gz";

This basically dumps every revision from each repository in your server, and¬†gzip’s them and then puts them in /home/user/svn/backup under the current date

SSH Clears Terminal on disconnection

I found on some servers that when I disconnect from an SSH connection, the terminal console is cleared.

This is very annoying if I have to SCP a file after disconnecting, and I cannot remember the path/filename.

So, on the remote server, check the .bash_logout file in the user’s home folder. This will contain commands to run when that user disconnects, and in this particular case, it had


I commented that out, and we’re sorted. (Mind you, you might want to check with the server administrator before fiddling as it could be a server/company policy)