Dr. Mark Humphrys

School of Computing. Dublin City University.

Home      Blog      Teaching      Research      Contact

Search:

CA249      CA318      CA425      CA651

w2mind.computing.dcu.ie      w2mind.org


Sample Shell programs



norm - set permissions as open as possible

chmod  u+rwx,go+rx-w  $*



hide - as hidden as possible

chmod  u+rwx,go-rwx  $*



semihide - just open enough as needed for Web

directories:

chmod  u+rwx,g-rwx,o+x-rw  $*
files (web pages, images, etc):
chmod  u+rwx,g-rwx,o+r-xw  $*
CGI scripts:
chmod  u+rwx,g-rwx,o+rx-w  $*
"norm" could of course replace all 3 if you don't mind granting more access than strictly necessary.



rmifexists - silent repeated delete

e.g. Want to be able to repeatedly run:
rmifexists *.bak
and not get error message if no *.bak files found.

for i in $*
do
        if test -f $i
        then
         rm $i
        fi
done



Exercise

Why not:

        if test -f $*
        then
         rm $*
        fi



myspace - which of my directories use the most space

cd $HOME
du | sort -n



wipe - clean up editor backup files

rmifexists *%
rmifexists .*% 

rmifexists  *~
rmifexists .*~

rmifexists  *.bak
rmifexists .*.bak

rmifexists  *.BAK
rmifexists .*.BAK
Certainly easier than having to point-and-click each one.


Exercise

Write a recursive wipe.




Feeds      HumphrysFamilyTree.com

Bookmark and Share           On Internet since 1987.