#!/bin/bash
exec /usr/bin/fdupes "${@}" # this is in development
#                       /usr/local/bin/fdupes
# https://crystalfaeries.net/posix/bin/fdupes
# celeste:crystalfaery FDUPES 2017-07-14 03:40:25+00:00
let help=4
# i, celeste:crystalfaery, am beginning to write a shell-script replacement for the program: /usr/bin/fdupes
# BECAUSE the virtual servers at bluehost.com running CentOS,
# do not allow root access by which I would be able to actually install /usr/bin/fdupes :-(
# "cheap hosting has its costs"			-- celeste:crystalfaery
# "there is no substitute for DebIan Linux(TM)"	-- celeste:crystalfaery
# 
# I am using fdupes as follows: fdupes -1 -r .
# in my script /usr/local/bin/fdedupe
# and initially shall not attempt to replicate any other arguments but help and version
# I have extracted relevant man page details:
# 
# FDUPES(1)                                                 General Commands Manual                                                 FDUPES(1)
# 
# NAME
#        fdupes - finds duplicate files in a given set of directories
# 
# SYNOPSIS
#        fdupes [ options ] DIRECTORY ...
# 
# DESCRIPTION
#        Searches the given path for duplicate files. Such files are found by comparing file sizes and MD5 signatures, followed by a byte-by-
#        byte comparison.
# 
# OPTIONS
#        -r --recurse
#               for every directory given follow subdirectories encountered within
# 
#        -1 --sameline
#               list each set of matches on a single line
# 
# NOTES
#        When -1 or --sameline is specified, spaces and backslash characters  (\) appearing in a filename are preceded by a backslash characā€
#        ter.
# 
# CAVEATS
#        [...] when  specifying  a  particular  directory more than once, all files within that directory will be listed as their own
#        duplicates, leading to data loss should a user preserve a file without its "duplicate" (the file itself!).
# 
# AUTHOR
#        Adrian Lopez <adrian2@caribe.net>

if [ -x `which /usr/bin/fdupes` ]
then	# YAY, we're probably on an actual Linux(TM) system, instead of some crippleware
	exec /usr/bin/fdupes "$@"	# pass the arguments on through to the REAL program
	exit	-1			# exec never returns
else
	echo "This system does not offer /usr/bin/fdupes" 1>&2
	exit	-2			# OOPS, we need to yet code the replacement...
# DEVELOPMENT BEGIN
	maxdepth="-maxdepth 1 "	# default to non-recursion
	sameline="-sameline "	# default to one line per file (probably not what find will accept!)
	while [ $# -ne 0 ]
	do case "${1}" in
	-h, --help)
		head -n $help $0
		exit	0
		;;
	-v, --version)
		grep FDUPES $0
		exit	0
		;;
	-r, --recurse)
		maxdepth=""
		break
		;;
	-1 --sameline)
		sameline=""
		break
		;;
	*)
		echo "$0 does not cognize ${1}" 1>&2	# argument is neither a directory nor one we coded yet
		exit	1
		;;
	esac
	shift	# done with this argument
	done
# DEVELOPMENT END
fi

exit -3					# whoa, please explain how we erroneously arrived here?



syntax highlighted by Code2HTML, v. 0.9.1