From b46fd58c697af0f046d24f693d6ff6e9d82f9b5e Mon Sep 17 00:00:00 2001 From: "Matthew O. Persico" Date: Thu, 4 Apr 2019 17:42:45 -0400 Subject: [PATCH] Added a bit about full paths and 'find' --- SC2012.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/SC2012.md b/SC2012.md index 97f0efc..978e8d6 100644 --- a/SC2012.md +++ b/SC2012.md @@ -69,6 +69,21 @@ $ find .snapshot -maxdepth 1 ! -name .snapshot .snapshot/rnapdev1-svm_4_05am_6every4hours.2019-04-02_1205 .snapshot/snapmirror.1501b4aa-3f82-11e8-9c31-00a098cef13d_2147868328.2019-04-01_190000 ``` + +**Note:** If the directory argument to find is a fully expressed path (`/home/somedir/.snapshot`), then you should use `basename` on the `-name` filter: + +``` +$ theDir="$HOME/.snapshot" +$ find "$theDir" -maxdepth 1 ! -name "$(basename $theDir)" +/home/matt/.snapshot/rnapdev1-svm_4_05am_6every4hours.2019-04-02_0005 +/home/matt/.snapshot/rnapdev1-svm_4_05am_6every4hours.2019-04-02_0405 +/home/matt/.snapshot/rnapdev1-svm_4_05am_6every4hours.2019-04-02_0805 +/home/matt/.snapshot/rnapdev1-svm_4_05am_6every4hours.2019-04-01_1605 +/home/matt/.snapshot/rnapdev1-svm_4_05am_6every4hours.2019-04-01_2005 +/home/matt/.snapshot/rnapdev1-svm_4_05am_6every4hours.2019-04-02_1205 +/home/matt/.snapshot/snapmirror.1501b4aa-3f82-11e8-9c31-00a098cef13d_2147868328.2019-04-01_190000 +``` + #### All the other info If trying to parse out any other fields, first see whether `stat` (GNU, OS X, FreeBSD) or `find -printf` (GNU) can give you the data you want directly.