Debian Codegraph @

wipedir.sh

raw symbols SCIP
1 #!/bin/bash
2
3 E_WRONG_DIRECTORY=85
4
5 clear # Clear the screen.
6
7 TargetDirectory=/home/bozo/projects/GreatAmericanNovel
8
9 cd $TargetDirectory
10 echo "Deleting stale files in $TargetDirectory."
11
12 if [ "$PWD" != "$TargetDirectory" ]
13 then # Keep from wiping out wrong directory by accident.
14 echo "Wrong directory!"
15 echo "In $PWD, rather than $TargetDirectory!"
16 echo "Bailing out!"
17 exit $E_WRONG_DIRECTORY
18 fi
19
20 rm -rf *
21 rm .[A-Za-z0-9]* # Delete dotfiles.
22 # rm -f .[^.]* ..?* to remove filenames beginning with multiple dots.
23 # (shopt -s dotglob; rm -f *) will also work.
24 # Thanks, S.C. for pointing this out.
25
26 # A filename (`basename`) may contain all characters in the 0 - 255 range,
27 #+ except "/".
28 # Deleting files beginning with weird characters, such as -
29 #+ is left as an exercise. (Hint: rm ./-weirdname or rm -- -weirdname)
30 result=$? # Result of delete operations. If successful = 0.
31
32 echo
33 ls -al # Any files left?
34 echo "Done."
35 echo "Old files deleted in $TargetDirectory."
36 echo
37
38 # Various other operations here, as necessary.
39
40 exit $result