#!/bin/bash

if [ $# -lt 2 ]
then
   echo "USAGE: $0 file1 file2 ..."
   echo hard link all the files together
   exit 0
fi

first=$1
shift

if [ ! -f "$first" ]
then
	echo error: \"$first\" is not a file!
	exit 1
fi

# "for other in $*" does NOT work when filenames contain whitespace
# ln "$first" "$1" : the "" allows whitespace (space, tab) in the filename

while [ $# -ne 0 ]
do
	# echo $# args, 1=\"$1\"
	rm -f "$1"
	ln "$first" "$1" || echo "error: cannot ln \"$first\" \"$1\""
	shift
done
