File: mkiconlinks.sh

package info (click to toggle)
gnome-themes 2.8.2-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 12,864 kB
  • ctags: 1,483
  • sloc: ansic: 20,310; sh: 10,988; makefile: 1,756; xml: 1,531; perl: 76; lisp: 13
file content (36 lines) | stat: -rwxr-xr-x 839 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh
# usage:
#	mkiconlinks linkdata icondir
#
# Linkdata file consists of lines of the form:
# 	filename1: filename2 filename3 ... filenameN
#
# For each line in the data file, the script creates a symbolic link to 
# $(icondir)/filename1 from each of $(icondir)/filename2, 
# $(icondir)/filename3 ... $(icondir)/filenameN.

exec < $1
cd $2

read NEXTLINE 
while [ ! -z "$NEXTLINE" ] ; do

	#Extract first field, minus its trailing colon
	ORIG_FILE=`echo $NEXTLINE | awk '/:/{print $1}' | sed -e 's/://'`

	#Extract list of following fields
	LINKTO=`echo $NEXTLINE | awk '/:/{for (i=2; i<=NF; i++) print $i}'`

	if [ ! -z "$LINKTO" ] ; then
		echo "Creating symlinks to `pwd`/$ORIG_FILE"
	fi

	#Link each pair in turn
	for i in $LINKTO ; do
		ln -s -f "$ORIG_FILE" "$i"
#		echo $i >> removable.txt
	done

	read NEXTLINE 
done
exit 0