Penguin, small TECH.BARWICK.DE
Shell and shell scripts
 

Recent posts

Categories

Archive

Syndication

 



Powered By

Info

Friday, April 12, 2013   5:34 PM

Wrapper script for find

I find (hah) myself using find a lot to locate file system objects in the current directory, however find recurses into subdirectories by default. Using the parameters -mindepth 1 -maxdepth 1 restrict find to the current directory, are however a pain to type each time.

To make my own personal life easier I created this wrapper script (named find1):

#!/bin/sh

if [ ($# < 1) ]; then
  FINDPATH=.
else 
  FINDPATH=$1
  shift
fi

find $FINDPATH -mindepth 1 -maxdepth 1 $@

which automatically prepends the -mindepth and -maxdepth to find (they need to be first in the argument list).


Posted in Shell | add a comment