[rescue] [OT} shell help

Marcin 'Rambo' Roguski rambo at id.uw.edu.pl
Sun Apr 4 08:45:29 CDT 2010


On Sun, 04 Apr 2010 09:31:50 -0400
Sridhar Ayengar <ploopster at gmail.com> wrote:

> You can deal with this by feeding awk(1) with find(1).

Actually: I quite nicely managed it myself, maybe in not the best elegant way but...

#!/bin/sh

n=1

find ../ -type f -iregex '.*\.jpe?g' | while read i; do
	airline=`echo ${i}|sed 's:\.\./\(.*\)/\(.*\), \(.*\) \([^ ]*[jpe?g]\):\3:i'`
	aircraft=`echo ${i}|sed 's:\.\./\(.*\)/\(.*\), \(.*\) \([^ ]*[jpe?g]\):\1, \2 \4:i'`

	padn=$(printf "%5d" $n)

	echo "$padn: Getting  $aircraft"
	echo -n "       Caught   "
	aircraft=`echo ${aircraft}|sed 's:\(../\)\?\(various\|.pending\|.unused\)/\?\([, ]\?\)::'`
	aircraft=`echo ${aircraft}|sed 's:/:, :'`
	aircraft=`echo ${aircraft}|sed 's:\([^ ]*\) and revisions, ::'`
	echo -n $aircraft

	if [ ! -d "${airline}" ]; then mkdir "${airline}"; fi
	if [ ! -f "${airline}/${aircraft}" ]; then (cd "${airline}" && ln -s "../$i" "${aircraft}"); 
	else echo " - already linked"; fi
	echo ""
	n=`expr $n + 1`
done



More information about the rescue mailing list