From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29142 invoked by alias); 29 Jun 2015 15:09:46 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20285 Received: (qmail 2219 invoked from network); 29 Jun 2015 15:09:44 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,T_HDRS_LCASE, T_MANY_HDRS_LCASE autolearn=ham autolearn_force=no version=3.4.0 X-AuditID: cbfec7f5-f794b6d000001495-92-55915d5818dd Date: Mon, 29 Jun 2015 15:59:27 +0100 From: Peter Stephenson To: Zsh Users' List Subject: Tip of the day: prune empty directory hierarchies Message-id: <20150629155927.289729cb@pwslap01u.europe.root.pri> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDLMWRmVeSWpSXmKPExsVy+t/xq7oRsRNDDY6slbbYcXIlowOjx6qD H5gCGKO4bFJSczLLUov07RK4MiYt3c5U0MdSMf3pEqYGxvnMXYycHBICJhJLWxawQNhiEhfu rWfrYuTiEBJYyijx7cgKdghnGpPEqx/XWSGcbYwSLQe/grWwCKhKzL0/mRXEZhMwlJi6aTYj iC0ioC6x4no7E4gtLGAlsePJE3YQm1fAXmLRtZVgNr+AvsTVv5+YIFbbS8y8coYRokZQ4sfk e2DzmQW0JDZva2KFsOUlNq95C3a2END8G3d3s09gFJiFpGUWkpZZSFoWMDKvYhRNLU0uKE5K zzXSK07MLS7NS9dLzs/dxAgJw687GJceszrEKMDBqMTDq2E7IVSINbGsuDL3EKMEB7OSCO+a sImhQrwpiZVVqUX58UWlOanFhxilOViUxHln7nofIiSQnliSmp2aWpBaBJNl4uCUamBsL+B0 fvdLUuWWw+++ivaVjB8Uc7Yfr79bMFHFjNPwns5HpgQvrdhHf9/rewgntIgIff2hFHwuLPOC e7Nz9Exlp1VWmh43f5Y9XvV/2XINP94LTt5v9sgapR8S+jk3+P48Aa815ztOe77mzmG5e+F2 RoTzvTqmE/ONpd4WfbjeIHrDMfeN/T0lluKMREMt5qLiRAAQmaegPwIAAA== In case anybody ever wanted this and there isn't a standard solution I don't know about... pws # Prune empty directory hierarchies below the current directory. That's # a hierarchy where everything underneath is itself a directory. # # The first search is slow, but subsequently it simply goes up one # directory each time so it's much faster. local -aU dirs dirs=(**/*(ND/^F)) while (( ${#dirs} )); do rmdir $dirs || return # print Pruhed ${#dirs} directories... dirs=(${^dirs:h}(ND/^F)) done