Welcome to the Cisco Academy for Vision Impaired Linux Wiki. |
Main /
Lecture9We spent the first half hour reviewing the regular expression homework and how to solve some of the trickier problems. We were reminded that Bookshare has the book on Awk and Sed, at as well as Unix Power Tools at There is the Ced and Awk pocket reference at and of course, Mastering Regular Expressions at Also useful, is the Regular Expression Pocket Reference For more advanced users, the Regular Expressions Cookbook We reviewed substitution in Ed: would replace dog with cat in just the first three lines. But only the first dog on each line would be replaced. If the range 1,3 were replaced with 1,$, then this substitution would occur on every line in the file, but only the first occurance of dog on each found line would be replaced because the /g wasn't included in the command. Note that a shorthand for 1,$ is to simply type a comma. so would do a global replace, but only on a single line, the current line which is referenced by dot. Since dot is the default when no range is specified, this command would replace three occurances of dog with cat if the current line indeed contained the word dog three times. To actually replace all occurrances of dog throughout the file, you'd need this command: For a more complex expression, the ampersand is used in ed, to substitute for the matched text. The ampersand is not a meta-character; it's an ed-specific indicator for the match. For example, you want each line to begin with a number sign because you are going to make this text in to an
extended comment for a script.
You'd do your global search and replace like this: We reviewed the expression to express all upper case characters and We reviewed alternation and the use of parenthesis as in We explored more territory with Processes And Jobs including the top command, and using grep as in Now to filter out only files beginning with an uppercase letter, this command would be Kerry used the double grep examples to demonstrate filtering process listings with ps -aux. He mistakenly suggests the -n option; it's in fact the -v option to "invert" the selection as the man page explains. -v says do not match lines with the given expression. For a simple example: So to display all processes that have an upper-case letter somewhere in the name, but are not owned by root, you could pipe grep in to grep as in We briefly covered the difference between a shell glob and a regular expression. A glob is also a syntax that can filter out filenames, similar but not exactly like the wildcards used in Windows and DOS. We also defined some topics for future lectures: apache is the most commonly used open-source web server. postfix and exim are mail transfer agents -- programs which manage mail on Linux systems. Samba is the set of programs which let a Linux file server pretend to the network that it is a Windows server sharing files. Smb is the network file sharing protocol used by Windows. We also chatted in general about these types of programs and what would be covered in upcoming lectures. We discussed web-based administrative interfacs including Webmin and CPanel. The simplify administration, for example enabling a user to change permissions or add a new user by clicking a few buttons, but they also lock users out of more complex administrative tasks. Virtual hosting refers to running more than one website on the same server. There are two types of virtual hosting schemes: IP-based and name-based. In IP-based virtual hosting, each site has its own IP which is mapped in the A records of the DNS server. In name-based virtual hosting, the browser asks the web server which site is being requested. The server hands out pages based on the name that the browser specified. The page request from the browser comes with a "host header" that tells the web server which virtual domain the browser is requesting. Returning to mail transfer agents, we learned they were responsible for sending, receiving email, plus transferring email to and from the internet and other networks. It is not a pop or imap server. It is not the program that actually displays the inbox and lets users compose mail. Programs that display email and let users compose, save and filter messages are called Mail User Agents. |