[rescue] [OT} shell help

der Mouse mouse at Rodents-Montreal.ORG
Sat Apr 3 06:28:06 CDT 2010

> I have a file based gallery of aircraft, sorted by aircraft type.

> Now I decided that I'll do sorting by airline.
> I therefore need a smart solution that does this:

> for the loop; do symlinks
> 	from ./type/registration, *airline* *
> 	to ./Airlines/airline/type, registration *;
> done

I'm not entirely sure what it is you already have.  For example is
"type" a literal string, or does it represent a variable string?  What
about "registration"?  What do the things after the ,s mean - are those
contents of files, or files in directories, or what?

I might not use sed at all, here.  There's comparatively little string
processing being done.  I'd probably do something like

ls */* | tr / \  | while read type reg; do
	airline=`fgrep airline "$type/$reg" | awk '{print $2;}'`
	mkdir -p "Airlines/$airline/$type"
	ln -s ../../../"$type/$reg" "Airlines/$airline/$type/$reg"

though, of course, depending on the answers to the questions that
probably needs tweaking.

/~\ The ASCII				  Mouse
\ / Ribbon Campaign
 X  Against HTML		mouse at rodents-montreal.org
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

More information about the rescue mailing list