Write a script in your favourite scripting language that does the 
following:

merge [-d] [-s] file1 file2 


merge two text files file1 and file2

-d remove duplicate entries

-s sort the entries
-----------------------------------

#!/bin/bash

# check number of arguments passed.
if (($# < 2)); then
	echo "Usage: merge [-d] [-s] file1 file2"
	exit 1
fi

#case: there are 2 params file1 and file2
if (($# == 2)); then	
	if [ -f $1 ]; then
		if [ -f $2 ]; then
			cat $1 $2	
		fi
	fi
	
	exit 1
fi

#case 3 params: -d file1 file2
if (($# == 3)); then	

	if (( $1 == "-d" )); then
		if [ -f $2 ]; then
			if [ -f $3 ]; then
				sort $2 $3 | uniq
				echo todo: keep originial order!
			fi
		fi
	fi

	exit 1
fi

#case 4 params: -s file1 file2
if (($# == 3)); then	

	if (( $1 == "-s" )); then
		if [ -f $2 ]; then
			if [ -f $3 ]; then
				sort $2 $3
			fi
		fi
	fi

	exit 1
fi

#case 5 params: -d -s file1 file2
if (($# == 4)); then	

	if (( $1 == "-d" )); then
		if (( $2 == "-s" )); then
			if [ -f $3 ]; then
				if [ -f $4 ]; then
					sort $3 $4 | uniq
				fi
			fi
		fi
	fi

	exit 1
fi