Dr. Mark Humphrys

School of Computing. Dublin City University.

Home      Blog      Teaching      Research      Contact

Search:

CA216      CA249      CA318

CA400      CA651      CA668


Lab - Shell



Shell scripts setup

  1. make a "bin" directory for your scripts, if such does not exist:
    • mkdir bin

  2. hide directory from others
    • chmod go-rwx bin

  3. Check $HOME/bin is in the PATH. (How?)

  4. With openSUSE, all you need do is make $HOME/bin, log off, log on again.

  5. We will edit Shell scripts in $HOME/bin




Exercise: d

  1. Make a program called "d" - detailed ls
    • ls -l $*
    • $* means all arguments that are passed to this script

  2. make prog executable
    • chmod +x d

  3. Run it.
    • d



Exercise: gnews

Another simple exercise:

Make a shell script called gnews.
Usage:

gnews someargument
It uses wget to grab today's news from, say, RTE.
It then searches the page (using grep) for the argument.


Feeds      w2mind.org

On Internet since 1987.