#!/bin/bash
#                       /usr/local/bin/lfind
#  http://crystalfaeries.net/posix/bin/lfind
# celeste:crystalfaery LFIND 2017-06-18 00:04:22+00:00
#
# "Local Find" is a shortcut to CLI find requests to stay "local" and not wander off into:
# system special directories:
#	/dev				# we don't really want to probe device files
#	/proc				# we don't really want to probe the kernel
#	/run				# we don't really want to probe process locks
#	/sys				# we don't really want to probe the kernel
# or system priveleged files restricted to root only access:
#	/root				# we usually don't have access unless superuser
#	/lost+found			# we usually don't have access unless superuser
#	/boot				# we don't need to see the contents of /boot
#	/rescue				# we don't need to see the backup copy of /boot
# backups or NAS: (sshfs or cifs mounts of Network Attached Storage):
#	/var/cache/dar			# darchive  backups
#	/var/cache/rsnapshot		# rsnapshot backups
#	/home/dar			# diskarchives
#	/home/rsnapshot			# rsnapshot backups
#
# NOTE:	We are only allowing one starting directory per find (lazy coding).	#	Incompatible
# NOTE:	-prune won't work if you append a trailing "/" to directory name.	#	Wrapper Filter Needed
# NOTE:	We force dereferencing of symlinks and do not cross to other filesystems.
searchdir="$1"; shift	# grab the first argument as the directory to search	####### ASSumption #######
find "$searchdir"/	-mount					    \( \( \
-path /boot							-prune -o \
-path /dev							-prune -o \
-path /etc.faerie						-prune -o \
-path /etc.pixy							-prune -o \
-path /etc/chatscripts						-prune -o \
-path /etc/cups/ssl						-prune -o \
-path /etc/ppp/peers						-prune -o \
-path /etc/skel/.config/google-chrome/Default			-prune -o \
-path /etc/skel/.config/google-chrome/PepperFlash		-prune -o \
-path /etc/skel/.config/menus/applications-merged		-prune -o \
-path /etc/skel/.config/pcmanfm/default				-prune -o \
-path /etc/skel/.config/xfce4/panel/launcher-10			-prune -o \
-path /etc/skel/.config/xfce4/panel/launcher-11			-prune -o \
-path /etc/skel/.config/xfce4/panel/launcher-12			-prune -o \
-path /etc/skel/.config/xfce4/panel/launcher-13			-prune -o \
-path /etc/skel/.config/xfce4/panel/launcher-9			-prune -o \
-path /etc/skel/.config/xfce4/xfconf/xfce-perchannel-xml	-prune -o \
-path /etc/skel/.gnome2						-prune -o \
-path /etc/skel/.kde/share					-prune -o \
-path /etc/ssl/private						-prune -o \
-path /home/lost+found						-prune -o \
-path /home/dar							-prune -o \
-path /home/downloads						-prune -o \
-path /home/public						-prune -o \
-path /home/rsnapshot						-prune -o \
-path /lost+found						-prune -o \
-path /proc							-prune -o \
-path /rescue							-prune -o \
-path /root							-prune -o \
-path /run							-prune -o \
-path /sys							-prune -o \
-path /var/cache						-prune -o \
-path /var/lib/dovecot						-prune -o \
-path /var/lib/fetchmail					-prune -o \
-path /var/lib/mysql						-prune -o \
-path /var/lib/PolicyKit					-prune -o \
-path /var/lib/polkit-1						-prune -o \
-path /var/lib/samba/usershares					-prune -o \
-path /var/lib/sudo						-prune -o \
-path /var/log/apache2						-prune -o \
-path /var/log/exim4						-prune -o \
-path /var/log/mysql						-prune -o \
-path /var/log/news/news.crit					-prune -o \
-path /var/log/news/news.err					-prune -o \
-path /var/log/news/news.notice					-prune -o \
-path /var/log/ntop						-prune -o \
-path /var/log/samba/cores					-prune -o \
-path /var/run							-prune -o \
-path /var/spool/						-prune -o \
-path /var/tmp							-prune -o \
-path /tmp							-prune \) \
-fprint	/tmp/find.prune.txt					\)     -o \
	\( "$@"	\)	# the rest of the search arguments ( all but the first one ( $searchdir ) )

# NOTE: for future coding hacks here troll these error messages for additional -path -prune:
# find: `/tmp/pulse-PKdhtXMmr18n': Permission denied
# find: `/boot/lost+found': Permission denied
# find: `/rescue/lost+found': Permission denied
# find: `/var/lost+found': Permission denied
# find: `/var/lib/udisks2': Permission denied
# find: `/var/lib/container': Permission denied
# find: `/var/lib/polkit-1': Permission denied
# find: `/var/lib/sudo/ts': Permission denied
# find: `/var/lib/sudo/lectured': Permission denied
# find: `/var/lib/postgrey': Permission denied
# find: `/var/lib/logcheck': Permission denied
# find: `/var/lib/fetchmail': Permission denied
# find: `/var/lib/postgresql/9.4/main': Permission denied
# find: `/var/lib/rkhunter/tmp': Permission denied
# find: `/var/lib/rkhunter/db': Permission denied
# find: `/var/lib/cron-apt/_-_etc_-_cron-apt_-_config': Permission denied
# find: `/var/lib/bluetooth': Permission denied
# find: `/var/lib/automysqlbackup': Permission denied
# find: `/var/log/speech-dispatcher': Permission denied
# find: `/var/log/psad/errs': Permission denied
# find: `/root': Permission denied
# find: `/run/udisks2': Permission denied
# find: `/run/dovecot/token-login': Permission denied
# find: `/run/dovecot/login': Permission denied
# find: `/run/cups/certs': Permission denied
# find: `/run/user/0': Permission denied
# find: `/run/postgresql/9.4-main.pg_stat_tmp': Permission denied
# find: `/run/alsa': Permission denied
# find: `/run/lvm': Permission denied
# find: `/run/systemd/inaccessible': Permission denied
# find: `/run/lock/lvm': Permission denied


syntax highlighted by Code2HTML, v. 0.9.1