Docsity

Unix Programming Environment: A Comprehensive Guide for Students, Lab Reports of Computer Science

Toggle sidebar
bg1
Unix Programming Environment1
• Objective: To introduce students to the
basic features of Unix and the Unix
Philosophy (collection of combinable tools
and environment that supports their use)
– Basic commands
– File system
–Shell
– Filters (wc, grep, sort, awk)
1Many of the examples for this lecture come
from the UNIX Prog. Env. and AWK books shown
(see lecture outline for full references)
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28

Partial preview of the text

Download Unix Programming Environment: A Comprehensive Guide for Students and more Lab Reports Computer Science in PDF only on Docsity!

Unix Programming Environment

  • Objective: To introduce students to the basic features of Unix and the UnixPhilosophy (collection of combinable toolsand environment that supports their use) - Basic commands – File system – Shell – Filters (wc, grep, sort, awk) 1 Many of the examples for this lecture come from the UNIX Prog. Env. and AWK books shown (see lecture outline for full references)

Getting Started

Getting a CS account

  • Lab in Univ. Crossings 151 – tux.cs.drexel.edu, queen.cs.drexel.edu – lab machines and tux running linux, queen running solaris http://www.cs.drexel.edu/page.php?name=accounts.html - ssh (part of Drexel CD) http://www.drexel.edu/IRT/services/software/ - cygwin (www.cygwin.com) - loggin on and out

Command Line Interface

[jjohnson@ws44 jjohnson]$ finger jmn27 Login: jmn Name: John Novatnack Directory: /home/jmn Shell: /usr/local/bin/tcsh On since Tue Nov 30 01:06 (EST) on pts/1 from mst.cs.drexel.edu 3 hours 38 minutes idle On since Tue Nov 30 01:33 (EST) on pts/3 from mst.cs.drexel.edu 3 hours 38 minutes idle Mail last read Tue Jan 4 15:53 2005 (EST) Plan: hey i'm john

Command Line Interface

  • options (usually designated with -) • who -q

man

$ man who WHO(1) User Commands WHO(1) NAME who - show who is logged on SYNOPSIS who [OPTION]... [ FILE | ARG1 ARG2 ] DESCRIPTION -a, --all same as -b -d --login -p -r -t -T –u …^ -q, --count all login names and number of users logged on … SEE ALSO The full documentation for who is maintained as a Texinfo manual. If the info and who programs are properly installed at your site, the command info coreutils who should give you access to the complete manual.

info

$ info who File: coreutils.info, Node: who invocation, Prev: users invocation, Up: User information who': Print who is currently logged in =======================================who' prints information about users who are currently logged on. Synopsis: who' [OPTION] [FILE] [am i] If given no non-option arguments,who' prints the following information for each user currently logged on: login name, terminal line, login time, and remote hostname or X display. If given one non-option argument, who' uses that instead of/etc/utmp' as the name of the file containing the record of users logged on. /etc/wtmp' is commonly given as an argument towho' to look at who has previously logged on.

File System

  • absolute and relative paths • /usr/me/stuff •. and .. • Commands for traversing file system
    • pwd, cd, ls
      • Commands for viewing files
        • cat, more, less

File System

  • absolute and relative paths • /usr/me/stuff •. and .. • Commands for traversing file system
    • pwd, cd, ls
      • Commands for viewing files
        • cat, more, less, od

File System

  • File permissions
    • owner, group, world (everyone else) – chgrp, chown, ls –l, chmod

File System

[jjohnson@ws44 winter]$ ls -l total 24 drwxr-xr-x 7 jjohnson users 80 Jan 3 2005 cs265/ -rw------- 1 jjohnson users 8258 Jan 3 2005 cs265.html -rw-r--r-- 1 jjohnson users 8261 Jan 3 2005 cs265.html~ [jjohnson@ws44 winter]$ chmod 644 cs cs cs265.html cs265.html~ [jjohnson@ws44 winter]$ chmod 644 cs265. cs265.html cs265.html~ [jjohnson@ws44 winter]$ chmod 644 cs265.html [jjohnson@ws44 winter]$ ls -l total 24 drwxr-xr-x 7 jjohnson users 80 Jan 3 2005 cs265/ -rw-r--r-- 1 jjohnson users 8258 Jan 3 2005 cs265.html -rw-r--r-- 1 jjohnson users 8261 Jan 3 2005 cs265.html~

editor

A text editor is used to create and modify files.

The most commonly used editors in the Unixcommunity are vi (improved vi – vim) and emacs - You must learn at least one of these editors (youcan get started quickly – use info and go through atutorial – and learn more as you start using it) - Tutorial for vim - $ vimtutor

filters

Programs that read some input, perform a simpletransformation on it, and write some output.

Examples - wc – tr – grep, egrep – sort – cut – uniq – head, tail

Regular Expressions

There are three operators used to build regularexpressions. Let R and S be regular expressionsand L(R) the set of strings that match R.

  • Union
    • R|S L(R|S) = L(R) ∪ L(S)
      • Concatenation
        • RS L(RS) = {rs, r ∈ R and s ∈ S}
          • Closure
            • R* L(R*) = { ε ,R,RR,RRR,…}

Regular Expressions

a|(ab)

(a|(ab))|(c|(bc)) - a* - ab - (ab)* - a|bcd - letter = a|b|c|…|z|A|B|C|…|Z|_ - digit = 0|1|2|3|4|5|6|7|8| - letter(letter|digit)