Dr. Mark Humphrys

School of Computing. Dublin City University.

Online coding site: Ancient Brain

coders   JavaScript worlds

Search:

Free AI exercises


Lab - Shell




One-off setup before writing shell scripts

Before starting writing shell scripts at all:
  1. Make sure your bin directory exists.
      mkdir $HOME/bin 

  2. Check it is in the PATH.
     echo $PATH 

  3. If not, you need to add $HOME/bin to the PATH.

  4. Optional: Hide your bin directory from other users:
      chmod go-rwx $HOME/bin 

  



Checklist for every shell script

For every Shell script you write, go through this checklist.

  
To make a new program called "prog":
  1. Put it in $HOME/bin

  2. Use a text editor to edit it.
    For example a GUI editor:
     gedit prog & 
    Or a command-line editor:
     nano prog  

  3. Make it executable:
     chmod +x prog 

  4. Run it:
     prog 
  


Exercise: d

Make a Shell script called "d" - detailed ls
  


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.


ancientbrain.com      w2mind.org      humphrysfamilytree.com

On the Internet since 1987.      New 250 G VPS server.

Note: Links on this site to user-generated content like Wikipedia are highlighted in red as possibly unreliable. My view is that such links are highly useful but flawed.