Finding out public IP from console on Linux


My site of choice to lookup my public IP is http://www.whatismyip.com. This is very easy to use from a browser but not as straight forward if you only have access to the console. The trick is to use wget and a regular expression to extrac the IP address.

The script below is taken from wolfvorkian1 at http://ubuntuforums.org/archive/index.php/t-228660.html

wget -qO - www.whatismyip.com/automation/n09230945.asp | egrep -m1 -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'

This will just display your external public IP

Advertisements

Deleting all folders and sub-folders with a given name with Windows Shell


This particular script came in handy when I copied a project that was under source control with SVN and wanted to “unbind” it. The easiest way to do that is to delete all the .svn folders and sub-folders inside the project’s directory.

This could be achieved by doing a search in Windows for “.svn”, selecting all the returned directories and deleting them. But if this way is not an option, here is a scrip that will do the trick:

for /f "tokens=* delims=" %%i in ('dir /s /b /a:d *svn') do (  rd /s /q "%%i")
  1. create a file with any text editor
  2. paste this script in
  3. save it with a .cmd extension (e.g. delete_svn.cmd)
  4. there are 2 ways to run the script:
    • from the Command Prompt
      • go to the top directory where you want to do the deletion (let’s call it working directory)
      • type [path_to_cmd_file]\delete_svn.cmd and then Enter
    • from the Windows Explorer
      • copy the .cmd file to the working directory
      • double-click on it

This should take care of recursively deleting all the directories called .svn