Added ionice in the find alias and the --group-directories-first in the ls aliases.
[scripts.git] / clean.sh
1 #!/bin/bash
2
3 #########################################################################
4 # This program is free software: you can redistribute it and/or modify  #
5 # it under the terms of the version 3 of the GNU General Public License #
6 # as published by the Free Software Foundation.                         #
7 #                                                                       #
8 # This program is distributed in the hope that it will be useful, but   #
9 # WITHOUT ANY WARRANTY; without even the implied warranty of            #
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      #
11 # General Public License for more details.                              #
12 #                                                                       #
13 # You should have received a copy of the GNU General Public License     #
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.  #
15 #                                                                       #
16 # Written by and Copyright (C) Francois Fleuret                         #
17 # Contact <francois@fleuret.org> for comments & bug reports             #
18 #########################################################################
19
20 TRASH=$(mktemp -d /tmp/trash.XXXXXX)
21
22 # "pdf:fig" "pdf:png" "pdf:pgm"
23
24 for i in "nav:tex" "snm:tex" "toc:tex" "blg:tex" \
25          "idx:tex" "ilg:tex" "ind:tex" "lof:tex" "lot:tex" "lou:tex" \
26          "dvi:tex" "log:tex" "aux:tex" "bbl:tex" \
27          "ps:tex" "pdf:tex" "out:tex" "tpt:tex" "brf:tex" \
28          "eps:fig" "eps:png" "eps:pgm" \
29          "o:cc" "o:c" ; do
30     PRODUCED=$(echo $i | cut -f 1 -d:)
31     SOURCE=$(echo $i | cut -f 2 -d :)
32     for f in *.$PRODUCED; do
33         ORIGINAL=${f/.$PRODUCED/.$SOURCE}
34         if [ -f "${ORIGINAL}" ]; then
35             echo "move $f to ${TRASH} ($ORIGINAL exists)"
36             mv $f ${TRASH}
37         fi
38     done
39 done
40
41 for i in "mozilla.ps" "a.out"; do
42     if [ -f "$i" ]; then
43         echo "move $i to ${TRASH}"
44         mv $i ${TRASH}
45     fi
46 done
47
48 for f in $(find -type f -executable); do
49     if [ -f ${f}.cc ] || [ -f ${f}.c ]; then
50         echo "move $f to ${TRASH} (source code exists)"
51         mv $f ${TRASH}
52     fi
53 done