<[EMAIL PROTECTED]> writes:
> Anyone else want to offer some neat, tricky, crafty
> additions for an (Linux) alias file ?
Most of what I include here will be useful to programmers, but some of
these are generally handy to all. Enjoy...
--kevin
# Author: Kevin D. Clark <alumni.unh.edu!kdc>
# these are intended to be stuck in your .kshrc .
# if you use csh you have my condolences...
alias kh="kill -HUP"
alias k9="kill -9"
alias cx="chmod +x"
srcfind () {
if [ $# -eq 0 ] ; then
echo srcfind: please enter a directory list
else
find "${@}" \( -name \*.c \
-o -name \*.cc \
-o -name \*.h \
-o -name \*.hh \
-o -name \*.java \
-o -name \*.c++ \
-o -name \*.el \
\) -print
fi
}
writeablesrcfind () {
if [ $# -eq 0 ] ; then
echo writeablesrcfind: please enter a directory list
else
find "${@}" \( -name \*.c \
-o -name \*.cc \
-o -name \*.h \
-o -name \*.hh \
-o -name \*.java \
-o -name \*.c++ \
-o -name \*.el \
\) \
-exec test -w {} \; \
-print
fi
}
# files that are relevant to our build
buildfind () {
if [ $# -eq 0 ] ; then
echo buildfind: please enter a directory list
else
find "${@}" \( -name \*.c \
-o -name \*.cc \
-o -name \*.h \
-o -name \*.java \
-o -name \*.c++ \
-o -name Makefile \
\) -print
fi
}
# files that are relevant to our build
newerbuildfind () {
if [ $# -lt 2 ] ; then
echo Usage: newerbuildfind file-with-timestamp directory1 directory2 ...
else
FILE=$1
shift
find "${@}" -newer $FILE \
\( -name \*.c \
-o -name \*.cc \
-o -name \*.h \
-o -name \*.java \
-o -name \*.c++ \
-o -name Makefile \
\) -print
fi
}
# files that are relevant to our build
writablebuildfind () {
if [ $# -eq 0 ] ; then
echo Usage: writablebuildfind file-with-timestamp directory1 directory2 ...
else
find "${@}" \( -name \*.c \
-o -name \*.cc \
-o -name \*.h \
-o -name \*.java \
-o -name \*.c++ \
-o -name Makefile \
\) \
-exec test -w {} \; \
-print
fi
}
txtfind () {
if [ $# -eq 0 ] ; then
echo txtfind: please enter a directory list
else
perl -MFile::Find -e 'find(sub{print "$File::Find::name\n" if (-f && -T);},
@ARGV);' "${@}"
fi
}
binfind () {
if [ $# -eq 0 ] ; then
echo binfind: please enter a directory list
else
perl -MFile::Find -e 'find(sub{print "$File::Find::name\n" if (-f && -B);},
@ARGV);' "${@}"
fi
}
cfind () {
if [ $# -eq 0 ] ; then
echo cfind: please enter a directory list
else
find "${@}" \( -name \*.c \
-o -name \*.cc \
-o -name \*.c++ \
\) -print
fi
}
hfind () {
if [ $# -eq 0 ] ; then
echo hfind: please enter a directory list
else
find "${@}" \( -name \*.h \
\) -print
fi
}
jfind () {
if [ $# -eq 0 ] ; then
echo jfind: please enter a directory list
else
find "${@}" \( -name \*.java \
\) -print
fi
}
elfind () {
if [ $# -eq 0 ] ; then
echo elfind: please enter a directory list
else
find "${@}" \( -name \*.el \
\) -print
fi
}
bakfind () {
if [ $# -eq 0 ] ; then
echo bakfind: please enter a directory list
else
find "${@}" \( -name \*.bak \
\) -print
fi
}
classfind () {
if [ $# -eq 0 ] ; then
echo classfind: please enter a directory list
else
find "${@}" \( -name \*.class \
\) -print
fi
}
writeablefind () {
if [ $# -eq 0 ] ; then
echo writeablefind: please enter a directory list
else
perl -MFile::Find -e 'find(sub{print "$File::Find::name\n" if (-f && -w);},
@ARGV);' "${@}"
fi
}
readonlyfind () {
if [ $# -eq 0 ] ; then
echo readonlyfind: please enter a directory list
else
perl -MFile::Find -e 'find(sub{print "$File::Find::name\n" if (-f && ! -w);},
@ARGV);' "${@}"
fi
}
# Finds all files and directories newer than a given file
newerfind () {
if [ $# -lt 2 ] ; then
echo newerfind: please enter a directory list
else
perl -MFile::Find -e '$f = shift; find(sub{print "$File::Find::name\n" if (-M $f >
-M);}, @ARGV);' "${@}"
fi
}
# controversial given the current discussion, but "whatever..."
# original idea from [EMAIL PROTECTED]
# slightly enhanced by acf
myrm()
{
for a
do
case "$a" in
\*) echo -n "rm: remove all? "
read ans
case "$ans" in
y*|Y*) ;;
*) set +f ; return 1;;
esac ;;
*) ;;
esac
done
set +f
\rm $(eval echo \"${@}\")
}
alias rm="set -f; myrm"
--
Kevin D. Clark (CetaceanNetworks.com!kclark) |
Cetacean Networks, Inc. | Give me a decent UNIX
Portsmouth, N.H. (USA) | and I can move the world
alumni.unh.edu!kdc (PGP Key Available) |
*****************************************************************
To unsubscribe from this list, send mail to [EMAIL PROTECTED]
with the text 'unsubscribe gnhlug' in the message body.
*****************************************************************