Skip to content
Snippets Groups Projects
Commit 40855756 authored by Mark Olesen's avatar Mark Olesen
Browse files

usage and argument handling for bin/rm* and bin/touch* utilities

parent de525cda
Branches
Tags
No related merge requests found
#!/bin/sh #!/bin/sh
find . \( -name '*.class' \) -print | xargs -t rm
# default is pwd
if [ "$#" -eq 0 ]
then
set -- .
elif [ "$1" = "-h" -o "$1" = "-help" ]
then
echo "Usage: ${0##*/} [dir1] .. [dirN]"
echo " remove all .class files"
exit 1
fi
for i
do
if [ -d "$i" ]
then
echo "removing all .class files"
find $i -name '*.class' -print | xargs -t rm
else
echo "no directory: $i"
fi
done
#------------------------------------------------------------------------------
#!/bin/sh #!/bin/sh
# find . \( -name 'core' \) -exec ls -l {} \; -exec rm {} \;
find . \( -type f -name 'core' -o -name 'core.[1-9]*' -o -name 'vgcore.*' \) -print | xargs -t rm # default is pwd
if [ "$#" -eq 0 ]
then
set -- .
elif [ "$1" = "-h" -o "$1" = "-help" ]
then
echo "Usage: ${0##*/} [dir1] .. [dirN]"
echo " remove all core files"
exit 1
fi
for i
do
if [ -d "$i" ]
then
echo "removing all core files"
find $i \( -type f -name 'core' -o -name 'core.[1-9]*' -o -name 'vgcore.*' \) -print | xargs -t rm
else
echo "no directory: $i"
fi
done
#------------------------------------------------------------------------------
#!/bin/sh #!/bin/sh
if [ $# -eq 0 ] if [ "$1" = "-h" -o "$1" = "-help" -o "$#" -gt 1 ]
then then
find . \( -name '*.dep' \) -print | xargs -t rm echo "Usage: ${0##*/} : remove all .dep files"
elif [ $# -eq 1 ] echo " ${0##*/} <file> : remove all .dep files referring to <file>"
exit 1
fi
if [ "$#" -eq 0 ]
then then
echo "Removing all dep files containing $1..." echo "removing all .dep files"
find . -name '*.dep' -exec grep "$1" '{}' \; -exec rm '{}' \; find . -name '*.dep' -print | xargs -t rm
else else
echo "Usage: ${0##/} to remove all .dep files" echo "removing all .dep files containing $1..."
echo " ${0##/} <file> to remove all .dep files referring to <file>" find . -name '*.dep' -exec grep "$1" '{}' \; -exec rm '{}' \;
exit 1
fi fi
#------------------------------------------------------------------------------
#!/bin/sh #!/bin/sh
find . \( -name '*.o' \) -print | xargs -t rm
# default is pwd
if [ "$#" -eq 0 ]
then
set -- .
elif [ "$1" = "-h" -o "$1" = "-help" ]
then
echo "Usage: ${0##*/} [dir1] .. [dirN]"
echo " remove all .o files"
exit 1
fi
for i
do
if [ -d "$i" ]
then
echo "removing all .o files: $i"
find $i -name '*.o' -print | xargs -t rm
else
echo "no directory: $i"
fi
done
#------------------------------------------------------------------------------
#!/bin/sh #!/bin/sh
# find . \( -name '*~' -o -name '.*~' \) -exec ls -l {} \; -exec rm {} \;
find . \( -name '*~' -o -name '.*~' \) -print | xargs -t rm # default is pwd
if [ "$#" -eq 0 ]
then
set -- .
elif [ "$1" = "-h" -o "$1" = "-help" ]
then
echo "Usage: ${0##*/} [dir1] .. [dirN]"
echo " remove all *~ files"
exit 1
fi
for i
do
if [ -d "$i" ]
then
echo "removing all *~ files"
find $i \( -name '*~' -o -name '.*~' \) -print | xargs -t rm
else
echo "no directory: $i"
fi
done
#------------------------------------------------------------------------------
#!/bin/sh #!/bin/sh
touch $FOAM_APPBIN/* if [ "$#" -ne 0 ]
then
echo "Usage: ${0##*/}"
echo " touch FOAM_APPBIN"
exit 1
fi
if [ -d "$FOAM_APPBIN" ]
then
echo "touching FOAM_APPBIN: $FOAM_APPBIN"
touch $FOAM_APPBIN/*
else
echo "no FOAM_APPBIN: $FOAM_APPBIN"
fi
#------------------------------------------------------------------------------
#!/bin/sh #!/bin/sh
find . \( -name '*.dep' \) -print | xargs -t touch # default is pwd
if [ "$#" -eq 0 ]
then
set -- .
elif [ "$1" = "-h" -o "$1" = "-help" ]
then
echo "Usage: ${0##*/} [dir1] .. [dirN]"
echo " touch all .dep files"
exit 1
fi
for i
do
if [ -d "$i" ]
then
echo "touching all .dep files: $i"
find $i -name '*.dep' -print | xargs -t touch
else
echo "no directory: $i"
fi
done
#------------------------------------------------------------------------------
#!/bin/sh #!/bin/sh
touch $FOAM_LIBBIN/* if [ "$#" -ne 0 ]
then
echo "Usage: ${0##*/}"
echo " touch FOAM_LIBBIN"
exit 1
fi
if [ -d "$FOAM_LIBBIN" ]
then
echo "touching FOAM_LIBBIN: $FOAM_LIBBIN"
touch $FOAM_LIBBIN/* $FOAM_LIBBIN/*/*
else
echo "no FOAM_LIBBIN: $FOAM_LIBBIN"
fi
#------------------------------------------------------------------------------
#!/bin/sh #!/bin/sh
find . \( -name '*.o' \) -print | xargs -t touch # default is pwd
if [ "$#" -eq 0 ]
then
set -- .
elif [ "$1" = "-h" -o "$1" = "-help" ]
then
echo "Usage: ${0##*/} [dir1] .. [dirN]"
echo " touch all .o files"
exit 1
fi
for i
do
if [ -d "$i" ]
then
echo "touching all .o files: $i"
find $i -name '*.o' -print | xargs -t touch
else
echo "no directory: $i"
fi
done
#------------------------------------------------------------------------------
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment