Using Heidimysql over SSH tunnel

HeidiSQL LogoIf  like me your servers block mysql from outside connections, you will need to use ssh tunneling if you want to use a gui tool like Heidimysql to manager your Mysql dbs. I struggled to get this new feature working in Heidi until i stumbled on a post by Casey Mclaughlin that contains the missing step (saving server public key to your Win registry using Plink.exe).

So hopefully if anyone finds this post, this will is the link.

Using find,sed and xargs to strip files from one folder that exist in another

Handy bash commands to remove copies of files that exist in two places when you only want unique files in each folder:

Folder A contains 20000 files
Folder B contains 50000 fies

… and you have accidentally copied all of folder A into folder B so you now have thousands of duplicate files in folder B.

You can easily strip out any files in Folder B from Folder A using 3 bash commands piped together like so:

find foldera/* | sed s@foldera/@folderb/@ | xargs rm -rf

  • find – locate all files in folder a (you can use any combination of find paramaters here of course)
  • sed – replace foldera with folder b in each line of the results
  • xargs – run the rm -rf command on the output from sed
This just save me a lot of  time. Hope it helps someone else.
Credits to CiaranG for the assist with piping find results into sed, nice work!

Searching folder of files for a string

Ill never remember this and its just come in very handy

grep -lr “string” path

-l – this makes it list the filenames where it finds the string
-r – this makes it recursively scan all sub folders


grep -lr “/var/www/proj” ./*

This would scan for the string “var/www/prog” in all files/folders starting from the current working directory.

Love linux!

Dropbox Tip #1 – Share your scripts on all your pcs

OK so this post is crazy simple but something i use all the time so here goes.

Problem. You finally get a bash script working at home and you forget to upload it but you really need it one day at work

Sound familiar? Used to happen to me all the time, well that and reformatting my laptop and forgetting to backup my scripts!!

Solution. Store your scripts in Dropbox and add the folder to you bashrc path

This post assumes you already have dropbox installed (if you havent, get it here cos its ultra cool and you can get a 2gb account free).

There are only two stages involved

Creation a bin folder inside your  dropbox

mkdir ~/Dropbox/bin

Add the dropbox bin folder to your bashrc path.

nano ~/.bashrc

Look for a line that looks like this (often at the end), if its not there create it and make sure you add the dropbox bin folde to the path. Note: You can add as many folders as you like here each seperated by a colon (the two dotted kind, not your lower intestine)


Before this will work you need to close the terminal window and start a new one,  the new path will then be accesible.

Make sure your scripts are executable as you normally would and you can run as usual, however now the scripts will be on all your dropbox enabled pcs too..

Repeat Stage 2 on all your other pcs (of course making sure dropbox is installed and synced first).

Additional note: You will need to make the scripts executable on all the pcs you have got dropbox on as the permissions are only relative to the local machine.

chmod +x ~/Dropbox/bin/*

Or do each file as you need to.

Another cool use of dropbox, many to follow!