diff --git a/openbis/resource/scripts/common.sh b/openbis/resource/scripts/common.sh
index 7e1fb5c8309b721131a8031f9088bad1366fb480..3c220deefde38b9b97ebd87af97e0f5af957d172 100755
--- a/openbis/resource/scripts/common.sh
+++ b/openbis/resource/scripts/common.sh
@@ -4,7 +4,7 @@
 
 SQL_DIR=../../source/sql/
 
-PREV_NUM=`ls -1 $SQL_DIR/postgresql | grep 0 | sort | tail -n 1 | sed /0/s///`
+PREV_NUM=`ls -1 $SQL_DIR/postgresql | grep 0 | sort | tail -n 1 | sed s/^0*//g`
 PREV_VER=`printf "%03d" $PREV_NUM`
 CUR_VER=`printf "%03d" $(( $PREV_NUM+1 ))`