new simple script, locates a filename passed to it in a directory hierarchy.
authorChris Koeritz <fred@gruntose.com>
Mon, 7 May 2012 02:20:26 +0000 (22:20 -0400)
committerChris Koeritz <fred@gruntose.com>
Mon, 7 May 2012 02:20:26 +0000 (22:20 -0400)
scripts/files/find_same_filename.sh [new file with mode: 0644]

diff --git a/scripts/files/find_same_filename.sh b/scripts/files/find_same_filename.sh
new file mode 100644 (file)
index 0000000..a407e7b
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+# finds the same file name within a hierarchy, if possible.
+
+name="$1"; shift
+search_dir="$1"; shift
+
+if [ -z "$name" -o -z "$search_dir" ]; then
+  echo This script needs two parameters, the filename to look for and the
+  echo directory hierarchy to look for it in.
+  exit 1
+fi
+
+# just get the filename or directory name component at the end.
+name="$(basename "$name")"
+
+find "$search_dir" -iname "$name"
+
+