DOC PREVIEW
DREXEL CS 265 - Unix Programming Environment

This preview shows page 1-2-3-19-20-38-39-40 out of 40 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 40 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 40 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 40 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 40 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 40 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 40 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 40 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 40 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 40 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Unix Programming Environment1Getting StartedCommand Line InterfaceCommand Line InterfaceSlide 5Getting HelpmaninfoFile SystemSlide 10Slide 11Slide 12Slide 13Slide 14shelleditorfiltersgrepRegular ExpressionsSlide 20Unix Syntax for Regular Expressionsgrep and egrep Regular Expressions (decreasing order of precedence)pipes and combining filtersAwkAwk FeaturesExampleAssociative ArraysExample using ArraysProblem 1Problem 1 SolutionProblem 2ApproachProblem 2 SolutionProblem 3 opts post pots spot stop topsSlide 35Problem 3 Solutionsign.csquash.awkAnagram FilterAnagram OutputUnix 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)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 solarishttp://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 outCommand Line Interface [jjohnson@ws44 jjohnson]$ echo hellohello[jjohnson@ws44 jjohnson]$ dateTue Nov 30 05:24:34 EST 2004[jjohnson@ws44 jjohnson]$ uptime 05:24:40 up 8 days, 5:19, 6 users, load average: 1.22, 1.26, 1.63[jjohnson@ws44 jjohnson]$ whoummaycoc pts/0 Nov 23 09:56 (node4.uphs.upenn.edu)jmn27 pts/1 Nov 30 01:06 (mst.cs.drexel.edu)kn42 pts/2 Nov 30 02:09 (n2-202-96.resnet.drexel.edu)jjohnson pts/4 Nov 30 05:23 (n2-19-88.dhcp.drexel.edu)ks347 pts/6 Nov 30 02:59 (pcp04354303pcs.glstrt01.nj.comcast.net)jmn27 pts/3 Nov 30 01:33 (mst.cs.drexel.edu)Command Line Interface[jjohnson@ws44 jjohnson]$ finger jmn27Login: jmn27 Name: John NovatnackDirectory: /home/jmn27 Shell: /usr/local/bin/tcshOn since Tue Nov 30 01:06 (EST) on pts/1 from mst.cs.drexel.edu 3 hours 38 minutes idleOn since Tue Nov 30 01:33 (EST) on pts/3 from mst.cs.drexel.edu 3 hours 38 minutes idleMail last read Tue Jan 4 15:53 2005 (EST)Plan:hey i'm johnCommand Line Interface•options (usually designated with -)•who -qGetting Help•manual$man who•info$info who•internetThe linux documentation project (http://www.tldp.org/)•safarionline •friends and othersman$ man whoWHO(1) User Commands WHO(1)NAME who - show who is logged onSYNOPSIS 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 whoFile: 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 followinginformation for each user currently logged on: login name, terminalline, 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 userslogged on. `/etc/wtmp' is commonly given as an argument to `who' tolook at who has previously logged on.File System•Organized into a tree of directories starting at the root / / / | \ \ bin dev etc usr tmp / | \ me you them / \ junk stuffFile System•absolute and relative paths•/usr/me/stuff•. and ..•Commands for traversing file system–pwd, cd, ls•Commands for viewing files–cat, more, lessFile System•absolute and relative paths•/usr/me/stuff•. and ..•Commands for traversing file system–pwd, cd, ls•Commands for viewing files–cat, more, less, odFile System•Commands for copying, removing and linking files–cp, mv, rm, ln•Commands for creating and removing directories–mkdir, rmdir•Archiving directory structure–tar, gzip, gunzipFile System•File permissions –owner, group, world (everyone else)–chgrp, chown, ls –l, chmodFile System[jjohnson@ws44 winter]$ ls -ltotal 24drwxr-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 cscs265 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 -ltotal 24drwxr-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~shell•command interpreter (bash, sh, csh,…)•.bashrc, .profile•PATH and shell variables•metacharacters•history and command completion•file redirection•pipes•process managementeditor•A text editor is used to create and modify files.•The most commonly used editors in the Unix community are vi (improved vi – vim) and emacs•You must learn at least one of these editors (you can get started quickly – use info and go through a tutorial – and learn more as you start using it)•Tutorial for vim–$ vimtutorfilters•Programs that read some input, perform a simple transformation on it, and write some output.•Examples–wc–tr–grep, egrep–sort–cut–uniq–head, tailgrep•search for lines matching pattern in specified files.–In the simplest case, search for given string (file and matching line are shown)$ grep main *.cppassign31.cpp: * The main program queries the user to provide assignments of truth values to theassign31.cpp:int main()bestval.cpp:int main()bestval.cpp: string remainder; /* read remainder of line */bestval.cpp: getline(cin, remainder);max.cpp:int main()set.cpp:int main()tstr.cpp:int main()•More generally regular expressions are used for patternsRegular Expressions•There are three operators used to build regular


View Full Document

DREXEL CS 265 - Unix Programming Environment

Download Unix Programming Environment
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Unix Programming Environment and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Unix Programming Environment 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?