From 7bb6d2a4726e67fd3ad1f2892f58751c6aa0868f Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 10 Apr 2012 19:27:20 +0000 Subject: made script to move a patch's position on the screen, useful for standardizing help patch locations svn path=/trunk/; revision=16117 --- scripts/move-patch-to-xy | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 scripts/move-patch-to-xy (limited to 'scripts/move-patch-to-xy') diff --git a/scripts/move-patch-to-xy b/scripts/move-patch-to-xy new file mode 100755 index 00000000..79e71367 --- /dev/null +++ b/scripts/move-patch-to-xy @@ -0,0 +1,23 @@ +#!/bin/bash + +if [ $# -eq 1 ]; then + patch="$1" + newx=`expr $RANDOM % 200 + 100` + newy=`expr $RANDOM % 100 + 50` +elif [ $# -eq 3 ]; then + patch="$1" + newx=$2 + newy=$3 +else + echo "Move a patch to a given (x,y) location on the screen" + echo "Usage: $0 patch [x] [y]" + exit +fi + +firstline=`head -1 "$patch"` +x=`echo $firstline | sed 's|^#N canvas \([0-9][0-9]*\) [0-9 ;-]*$|\1|'` +y=`echo $firstline | sed 's|^#N canvas [0-9][0-9]* \([0-9][0-9]*\) [0-9 ;-]*$|\1|'` + +replaceline=`echo $firstline | sed "s|canvas $x $y|canvas $newx $newy|"` +echo replace first line with: $replaceline +sed -i "s|$firstline|$replaceline|" $patch -- cgit v1.2.1