Regular expressions and sed & awk
|
|
|
- Magdalen Blair
- 9 years ago
- Views:
Transcription
1 Regular expressions and sed & awk Regular expressions Key to powerful, efficient, and flexible text processing by allowing for variable information in the search patterns Defined as a string composed of letters, numbers, and special symbols, that defines one or more strings You have already used them in selecting files when you used asterisk (*) and question mark characters to select filenames Used by several Unix utilities such as ed, vi, emacs, grep, sed, and awk to search for and replace strings Checking the author, subject, and date of each message in a given mail folder egrep "ˆ(From Subject Date): " <folder> The quotes above are not a part of the regular expression but are needed by the command shell The metacharacter (or) is a convenient one to combine multiple expressions into a single expression to match any of the individual expressions contained therein The subexpressions are known as alternatives A regular expression is composed of characters, delimiters, simple strings, special characters, and other metacharacters defined below Characters A character is any character on the keyboard except the newline character \n Most characters represent themselves within a regular expression All the characters that represent themselves are called literals A special character is one that does not represent itself (such as a metacharacter) and needs to be quoted The metacharacters in the example above (with egrep) are ", ˆ, (,, and ) We can treat the regular expressions as a language in which the literal characters are the words and the metacharacters are the grammar Delimiters A delimiter is a character to mark the beginning and end of a regular expression Delimiter is always a special character for the regular expression being delimited The delimiter does not represent itself but marks the beginning and end of the regular expression Any character can be used as a delimiter as long as it (the same character) appears at both ends of the regular expression More often than not, people use forward slash / as the delimiter (guess why) If the second delimiter is to be immediately followed by a carriage return, it may be omitted Delimiters are not used with the grep family of utilities The metacharacters in the regular expressions are ˆ $. * [ ] \{ \} \ \( \) In addition, the following metacharacters have been added to the above for extended regular expressions (such as the one used by egrep) +? ( ) The dash (-) is considered to be a metacharacter only within the square brackets to indicate a range; otherwise, it is treated as a literal
2 Regular Expressions/sed/awk 2 Even in this case, the dash cannot be the first character and must be enclosed between the beginning and the end of range characters The regular expression search is not done on a word basis but utilities like egrep display the entire line in which the regular expression matches Simple strings The most basic regular expression Matches only itself Examples Reg. Exp. Matches Examples /ring/ ring ring spring ringing stringing /Thursday/ Thursday Thursday Thursday s /or not/ or not or not poor nothing Special characters Cause a regular expression to match more than one string Period Matches any character Examples Reg. Exp. Matches Examples /.alk/ All strings that contain a space will talk followed by any character may balk followed by alk Square brackets /.ing/ all strings with any character singing preceding ing ping before inglenook / / Date with any separator 09/17/ Define a class of characters that matches any single character within the brackets If the first character immediately following the left square bracket is a caret ˆ, the square brackets define a character class that match any single character not within the brackets A hyphen can be used to indicate a range of characters Within a character class definition, the special characters (backslash, asterisk, and dollar signs) lose their special meaning A right square bracket appearing as a member of the character class can only appear as the first character following the square bracket A caret is special only if it is the first character following the square bracket A dot within square brackets will not be a metacharacter /07[.-]17[.-]98/ will not match 07/17/98 but will match Examples
3 Regular Expressions/sed/awk 3 Asterisk Reg. Exp. Matches Examples /[bb]ill/ Member of the character class bill b and B followed by ill Bill billed /t[aeiou].k/ t followed by a lowercase talkative vowel, any character, and a k stink teak tanker /number [6-9]/ number followed by a space number 60 and a member of the character number 8: class 6 through 9 get number 9 /[ˆa-zA-Z]/ any character that is not a 1 letter } Stop! Can follow a regular expression that represents a single character Represents zero or more occurrences of a match of the regular expression An asterisk following a period matches any string of characters A character class definition followed by an asterisk matches any string of characters that are members of the character class A regular expression that includes a special character always matches the longest possible string, starting as far toward the beginning (left) of the line as possible Examples Reg. Exp. Matches Examples /ab*c/ a followed by zero or more b s ac followed by a c abc abbc debbcaabbbc Caret and dollar sign /ab.*c/ ab followed by zero or more other abc characters followed by a c /t.*ing/ t followed by zero or more thing characters followed by ing abxc ab45c xab x cat ting I thought of going /[a-za-z ]*/ a string composed only of letters 1. any string without and spaces numbers or punctuation! /(.*)/ as long a string as possible Get (this) and (that); between ( and ) /([ˆ)]*)/ the shortest string possible that (this) starts with ( and ends with ) Get (this and that) A regular expression beginning with a caret ˆ can match a string only at the beginning of a line The regular expression cat finds the string cat anywhere on the line but ˆcat matches only if the string cat occurs at the beginning of the line ˆ is used to anchor the match to the start of the line A dollar sign $ at the end of a regular expression matches the end of a line The regular expression cat finds the string cat anywhere on the line but cat$ matches only if the string cat occurs at the end of the line, it cannot be followed by any character but newline (not even space)
4 Regular Expressions/sed/awk 4 Rules Examples Character classes in range pattern Reg. Exp. Matches Examples /ˆT/ a T at the beginning of a line This line... That time... /ˆ+[0-9]/ a plus sign followed by a number at the beginning +759 Keep this... of a line /:$/ a colon that ends a line...below: Define specific character classes as follows [:digit:] Numbers from 0 to 9 [:alpha:] Any alphabetic character (upper- or lower-case) [:alnum:] Any letter or number; alphanumeric [:lower:] Any lower-case character [:upper:] Any upper-case character Quoting special characters Any special character, except a digit or a parenthesis, can be quoted by preceding it with a backslash Quoting a special character makes it represent itself Examples Reg. Exp. Matches Examples /end\./ all strings that contain end The end. Range metacharacters followed by a period send. pretend.mail /\\/ a single backslash \ /\*/ an asterisk *.c an asterisk (*) /\[5\]/ [5] it was five [5] /and\/or/ and/or and/or Used to match a number of expressions Described by the following rules r\{n\} Match exactly n occurrences of regular expression r r\{n,\} Match at least n occurrences of regular expression r r\{n,m\} Match between n and m occurrences of regular expression r Both n and m above must be integers between 0 and 256 For now, r must be considered to be a single character regular expression (strings must be enclosed in bracketed regular expressions) Word metacharacters The word boundaries in the regular expressions are denoted by any whitespace character, period, end-of-line, or beginning of line Expressed by \< beginning of word \> end of word Longest match possible A regular expression always matches the longest possible string, starting as far towards the beginning of the line as possible Empty regular expressions
5 Regular Expressions/sed/awk 5 An empty regular expression always represents the last regular expression used Let us give the following command to vi :s/mike/robert/ If you want to make the same substitution again, the following is sufficient :s//robert/ You can also do the following /mike/ :s//robert Bracketing expressions Regular expressions can be bracketed by quoted parentheses \( and \) Quoted parentheses are also known as tagged metacharacters The string matching the bracketed regular expression can be subsequently used as quoted digits The regular expression does not attempt to match quoted parentheses A regular expression within the quoted parentheses matches exactly with what the regular expression without the quoted parentheses will match The expressions /\(rexp\)/ and /rexp/ match the same patterns Quoted digits Within the regular expression, a quoted digit (\n) takes on the value of the string that the regular expression beginning with the nth \( matched Assume a list of people in the format last-name, first-name initial It can be changed to the format first-name initial last-name by the following vi command :%s/\([ˆ,]*\), \(.*\)/\2 \1/ Quoted parentheses can be nested There is no ambiguity in identifying the nested quoted parentheses as they are identified by the opening \( Example /\([a-z]\([a-z]*\)x\) matches 3 t dmnorx7 l u Replacement string vi and sed use regular expressions as search strings with the substitute command Ampersands (&) and quoted digits (\n) can be used to match the replacement strings within the replacement string An ampersand takes on the value of the string that the search string matched Example Redundancy :s/[[:digit:]][[:digit:]]*/number &/ You can write the same regular expression in more than one way To search for strings grey and gray in a document, you can write the expression as gr[ae]y, or grey gray, or gr(a e)y In the last case, parentheses are required as without those, the expression will match gra or ey which is not the intension
6 Regular Expressions/sed/awk 6 Regular expressions cannot be used for the newline character sed Stream editor Derivative of ed Takes a sequence of editor commands Goes over the data line by line and performs the commands on each line Basic syntax sed list of ed commands filename[s]... The commands are applied from the list in order to each line and the edited form is written to stdout Changing a pattern in the file sed does not alter the contents of the input file sed s/pat_1/pat_2/g in_file > out_file Quotes around the list of commands are necessary as the sed metacharacters should not be translated by the shell Selecting range of lines Command to remove the mail header from a saved mail message sed 1,/ˆ$/d in_file > out_file Removing the information from the output of the who command to get only the user id and login time Indenting a file one tab stop who sed s/ˆ\([ˆ ]*\).*\([0-9][0-9]:[0-9][0-9]\).*/\1\t\2/ The above matches all the lines (including empty lines) Problem can be solved by Another way to do it Multiple commands in the same invocation of sed sed s/ˆ/\t/ file sed /./s/ˆ/\t/ file sed /ˆ$/!s/ˆ/\t/ file ls -l sed s/ˆ *\([[:digit:]]*\).* \([ˆ ]*\)$/\1\t\2/ > 1d The commands must be on separate lines sed scripts
7 Regular Expressions/sed/awk 7 The sed commands can be put into script files and can be executed by Lines containing a pattern can be deleted by Automatic printing By default, sed prints each line on the stdout sed -f cmdfile in_file sed /rexp/d This can be inhibited by using the -n option as follows Matching conditions can be inverted by the! The last achieves the same effect as grep -v Inserting newlines sed -n /pattern/p sed -n /pattern/!p Converting a document from single space to double space sed s/$/\ / Creating a list of words used in the document sed s/[ \t][ \t]*/\ /g file Counting the unique words used in the document sed s/[ \t][ \t]*/\ /g file sed /ˆ$/d sort uniq wc -l Writing on multiple files $ sed -n /pat/w file1 > /pat/!w file2 filename Line numbering Line numbers can be used to select a range of lines over which the commands will operate Examples $ sed -n 20,30p $ sed 1,10d $ sed 1,/ˆ$/d $ sed -n /ˆ$/,/ˆend/p sed does not support relative line numbers (difference with respect to ed) awk Acronym for the last names of its designers Aho, Weinberger, Kernighan Not as good as sed for editing but includes arithmetic, variables, built-in functions, and a programming language like C; on the other hand, it is a more general processing model than a text editor
8 Regular Expressions/sed/awk 8 Table 1: Summary of sed commands a\ append lines to output until one not ending in \ b label branch to command : label c\ change lines to following text (as in a\ d delete lines i\ insert following text before next output l list line, making all non-printing characters visible (tabs appear as >; lines broken with \) p print line q quit (for scripts) r file read file, copy contents to stdout s/pat1/pat2/f substitute pat2 for pat1 f = g, replace all occurrences f = p, print f = w file, write to file t label test: branch to label if substitution made to current line w file write line(s) to file y/str1/str2/ replace each character from str1 with corresponding character from str2 (no ranges allowed = print current input line number!cmd do sed cmd if line is not selected : label set label for b and t commands { treat commands up to the matching } as a group Looks more like a programming language rather than a text editor Mostly used for formatting reports, data entry, and data retrieval to generate reports awk is easier to use than sed but is slower Usage is The awk_script looks like Input-driven language awk awk_script files pattern { action } pattern { action }... awk reads one line in the file at a time, compares with each pattern, and performs the corresponding action if the pattern matches There is no effect if the input file is empty Run the following commands to see the effect: touch foobar awk {print "Hello World"} foobar echo "Line 1" >> foobar awk {print "Hello World"} foobar echo "Line 1" >> foobar awk {print "Hello World"} foobar
9 Regular Expressions/sed/awk 9 As it reads each line, awk immediately breaks those up into segments (fields) based on a specified field separator (FS) If you want to make awk work on empty fle, you can use the keyword BEGIN Just like sed, awk does not alter its input files awk BEGIN {print "Hello World"} The patterns in awk can be regular expressions, or C-like conditions grep can be written in awk as awk /regular expression/ { print } filename Printing a message for each blank line in file awk /ˆ$/ { print "Encountered a blank line" } filename Either of pattern or action is optional and can be omitted Omitting pattern performs the action on every line Omitting action prints matched lines awk { print } filename awk /regular expression/ filename Just like sed, the awk_script can be presented to awk from a file by using awk programming model Fields Main input loop awk -f awk_script_file filename Loop reads each line of input from file and makes it available for processing Loop iterates as many times as the lines of input Loop terminates when there is no more input to be read Two special keywords BEGIN and END specify the commands to be executed before the beginning of loop and at the end of loop, respectively The blocks specified by these two keywords are optional A field is a string of characters, separated by FS By default, FS is any whitespace character FS can be specified by a command line option Changing the field separator to colon (:) awk -F: /regular expression/ { action } file To print the user names and real names in the passwd file awk -F: {print $1"\t"$5} /etc/passwd The output of who has six fields as follows sanjiv console Nov 18 13:26 sanjiv ttyp0 Nov 18 13:26 (:0.0) sanjiv ttypc Nov 19 13:27 (:0.0) vlad ttyp7 Nov 19 16:46 (arrak13.umsl.edu)
10 Regular Expressions/sed/awk 10 Printing Patterns The fields are called $1, $2,..., $NF NF is a variable whose value is set to the number of fields NF and $NF are not the same NF is the number of fields $NF is the contents (string) of the last field The current input line (or record) is tracked by the built-in variable NR The entire input record is contained in the variable $0 To add line numbers to each line, you can use the following awk {print NR, $0} filename Fields separated by comma are printed separated by the field separator a blank space character by default Complete control of the output format can be achieved by using printf instead of print as follows awk { printf "%4d %s\n", NR, $0 } filename printf in awk is almost identical to the corresponding C function Checking for people who do not have a password entry in the file /etc/passwd Checking for people who have a locked password entry Other ways to check for empty string awk -F: $2 == "" /etc/passwd awk -F: $2 == "*" /etc/passwd $2 == "" 2nd field is empty $2 /ˆ$/ 2nd field matches empty string $2! /./ 2nd field does not match any character length($2) == 0 length of 2nd field is zero The symbol indicates a regular expression match while! indicates a regular expression non-match length is a built-in function to count the number of characters in the string (or field) Any pattern match can be preceded by! to negate its match as follows awk -F:!( $2 == "" ) filename Data validation using the number of fields as criterion line valid if the number of fields is odd Printing excessively long lines (> 72 characters) Above problem with more informative solution print $LINE awk NF % 2!= 0 awk length($0) > 72 filename $ awk (length($0) > 72) \ { print "Line", NR, "too long: ", substr($0,1,50)} filename The function substr( s, m, n) produces the substring of s beginning at position m and with a length of n characters; if n is omitted, it continues to the end of string Extracting information with substr
11 Regular Expressions/sed/awk 11 $ date Wed Nov 20 14:27:33 CST 1996 $ date awk { print substr ( $4, 1, 5 ) } 14:27 The BEGIN and END patterns Special patterns used in awk scripts BEGIN actions are performed before the first input line has been read (used to initialize variables, print headings, and like) Setting the field separator within the script $ awk BEGIN {FS = ":"} > $2 == "" /etc/passwd END actions are done after the last line has been processed Printing the number of lines in the input awk END { printf NR }... Arithmetic and variables awk allows you to do more sophisticated arithmetic compared to the shell Adding the numbers in a column (first column), and printing the sum and average { s = s + $1 } END { print s, s/nr } Variables can be created by users and are initialized to zero by default awk also allows for shorthand arithmetic operators like C { s += $1 } END { print s, s/nr } Implementing wc in all its generality $ awk { nc += length ( $0 ) + 1 # number of chars, 1 for \n nw += NF # number of words } END { print NR, nw, nc } filename Variables can also store string of characters and the interpretation is based on context awk maintains a number of built-in variables of both types Developing man pages with [nt]roff Acts oddly on nights with full moon. BUGS section for catman from 4.2BSD Unix manual nroff and troff Native Unix programs to format text Based on requests within the documents that start with a period in the first column Commonly used requests are
12 Regular Expressions/sed/awk 12 The manual page.i Italicize following line.b Following line in bold.r Following line in Roman.br Break the line.ce Center the following line.fi Fill lines (Align right margins).ft Set font.na No right alignment.nf Do not fill lines (Preferable to.na).sp One vertical line Stored in a subdirectory in the directory /usr/man The subdirectory is called manx where x is a digit or character to indicate the section of the manual The sections are numbered 1 to 8 and n and l Printed with the man(1) command 1 User commands 2 System calls 3 C Library functions 4 Devices and network interfaces 5 File formats 6 Games and demos 7 Environments, tables, and troff macros 8 Maintenance commands l Misc. reference manual pages (Locally developed and installed) n Misc. reference manual pages (New commands) A shellscript that runs nroff -man but may be compiled on newer machines The locally developed man pages can be tested for printing with nroff -man command The man pages in a given section can be printed by specifying the section number, for example, the man page for the system call umask can be printed by typing the command man 2 umask If the section number is not specified, the output will be for the user command from section 1 The macros for man are discussed in section 7 of the manual and can be invoked by No manuals on the kernel man 7 man Usual device driver man pages are user-level descriptions and not internal descriptions A regular joke was Anyone needing documentation to the kernel functions probably shouldn t be using them. /* you are not expected to understand this */ from Unix V6 kernel source Layout of a Unix manual page The manual page is laid out as per the specifications in the man macro of troff Any text argument may be zero to six words Quotes can be used to include the space character in a word Some native nroff conventions are followed, for example, if text for a command is empty, the command is applied to the next line A line starting with.i and with no other inputs italicizes the next line The prevailing indentation distance is remembered between successive paragraphs but not across sections The basic layout of a man page is described by
13 Regular Expressions/sed/awk 13.TH COMMAND <section-number>.sh NAME command \- brief description of function.b command options.sh DESCRIPTION Detailed explanation of programs and options. Paragraphs are introduced by.pp.pp This is a new paragraph..sh FILES Files used by the command, e.g., passwd(1) mentions /etc/passwd.sh "SEE ALSO" References to related documents, including other manual pages.sh DIAGNOSTICS Description of any unusual output (e.g., see cmp(1)).sh BUGS Surprising features (not always bugs) If any section is empty, its header is omitted The.TH line and the NAME, SYNOPSIS, and DESCRIPTION sections are mandatory The.TH line Begins a reference page The full macro is described by.th command section date_last_changed left_page_footer center_header Sets prevailing indent and tabs to 0.5 The.SH lines Section headers Identify sections of the manual page NAME and SYNOPSIS sections are special; other sections contain ordinary prose NAME section Names the command (in lower case) Provides a one-line description of it SYNOPSIS section Names the options, but does not describe them The input is free form Font changes can be described with the.b,.i, and.r macros The name and options are bold while the rest of the information is in roman DESCRIPTION section Describes the commands and its options It tells the usage of the command The man page for cc(1) describes how to invoke the compiler, optimizer, where the output is, but does not provide a reference page for the manual The reference page can be cited in the SEE ALSO section However, man(7) is the description of the language of manual macros Command names and tags for options are printed in italics, using the macros.i (print first argument in italics) and.ir (print first argument in italic, second in roman) FILES section Mentions any files implicitly used by the commands
14 Regular Expressions/sed/awk 14 DIAGNOSTICS section Optional section and generally not present Reports any unusual output produced by the command May contain diagnostic messages, exit statuses, or surprising variations of the command s normal behavior BUGS section Could be called LIMITATIONS Reports shortcomings in the program that may need to be fixed in a future release Other requests and macros for man.ip x.lp.pp.ss Indented paragraph with a tag x Left-aligned paragraph Same as.lp Section subheading
Regular Expressions. In This Appendix
A Expressions In This Appendix Characters................... 888 Delimiters................... 888 Simple Strings................ 888 Special Characters............ 888 Rules....................... 891
Regular Expressions. Abstract
Regular Expressions Sanjiv K. Bhatia Department of Mathematics & Computer Science University of Missouri St. Louis St. Louis, MO 63121 email: [email protected] Abstract Regular expressions provide a powerful
grep, awk and sed three VERY useful command-line utilities Matt Probert, Uni of York grep = global regular expression print
grep, awk and sed three VERY useful command-line utilities Matt Probert, Uni of York grep = global regular expression print In the simplest terms, grep (global regular expression print) will search input
Lecture 18 Regular Expressions
Lecture 18 Regular Expressions Many of today s web applications require matching patterns in a text document to look for specific information. A good example is parsing a html file to extract tags
Hands-On UNIX Exercise:
Hands-On UNIX Exercise: This exercise takes you around some of the features of the shell. Even if you don't need to use them all straight away, it's very useful to be aware of them and to know how to deal
Lecture 4. Regular Expressions grep and sed intro
Lecture 4 Regular Expressions grep and sed intro Previously Basic UNIX Commands Files: rm, cp, mv, ls, ln Processes: ps, kill Unix Filters cat, head, tail, tee, wc cut, paste find sort, uniq comm, diff,
AN INTRODUCTION TO UNIX
AN INTRODUCTION TO UNIX Paul Johnson School of Mathematics September 24, 2010 OUTLINE 1 SHELL SCRIPTS Shells 2 COMMAND LINE Command Line Input/Output 3 JOBS Processes Job Control 4 NETWORKING Working From
Using Regular Expressions in Oracle
Using Regular Expressions in Oracle Everyday most of us deal with multiple string functions in Sql. May it be for truncating a string, searching for a substring or locating the presence of special characters.
Lecture 5. sed and awk
Lecture 5 sed and awk Last week Regular Expressions grep egrep Today Stream manipulation: sed awk Sed: Stream-oriented, Non- Interactive, Text Editor Look for patterns one line at a time, like grep Change
Unix Shell Scripts. Contents. 1 Introduction. Norman Matloff. July 30, 2008. 1 Introduction 1. 2 Invoking Shell Scripts 2
Unix Shell Scripts Norman Matloff July 30, 2008 Contents 1 Introduction 1 2 Invoking Shell Scripts 2 2.1 Direct Interpretation....................................... 2 2.2 Indirect Interpretation......................................
Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.
Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to
Python Lists and Loops
WEEK THREE Python Lists and Loops You ve made it to Week 3, well done! Most programs need to keep track of a list (or collection) of things (e.g. names) at one time or another, and this week we ll show
Moving from CS 61A Scheme to CS 61B Java
Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you
Advanced Bash Scripting. Joshua Malone ([email protected])
Advanced Bash Scripting Joshua Malone ([email protected]) Why script in bash? You re probably already using it Great at managing external programs Powerful scripting language Portable and version-stable
Cisco Networking Academy Program Curriculum Scope & Sequence. Fundamentals of UNIX version 2.0 (July, 2002)
Cisco Networking Academy Program Curriculum Scope & Sequence Fundamentals of UNIX version 2.0 (July, 2002) Course Description: Fundamentals of UNIX teaches you how to use the UNIX operating system and
Thirty Useful Unix Commands
Leaflet U5 Thirty Useful Unix Commands Last revised April 1997 This leaflet contains basic information on thirty of the most frequently used Unix Commands. It is intended for Unix beginners who need a
Regular Expressions. General Concepts About Regular Expressions
Regular Expressions This appendix explains regular expressions and how to use them in Cisco IOS software commands. It also provides details for composing regular expressions. This appendix has the following
Regular Expressions Overview Suppose you needed to find a specific IPv4 address in a bunch of files? This is easy to do; you just specify the IP
Regular Expressions Overview Suppose you needed to find a specific IPv4 address in a bunch of files? This is easy to do; you just specify the IP address as a string and do a search. But, what if you didn
Perl in a nutshell. First CGI Script and Perl. Creating a Link to a Script. print Function. Parsing Data 4/27/2009. First CGI Script and Perl
First CGI Script and Perl Perl in a nutshell Prof. Rasley shebang line tells the operating system where the Perl interpreter is located necessary on UNIX comment line ignored by the Perl interpreter End
A Crash Course on UNIX
A Crash Course on UNIX UNIX is an "operating system". Interface between user and data stored on computer. A Windows-style interface is not required. Many flavors of UNIX (and windows interfaces). Solaris,
Regular Expression Searching
Regular Expression Searching Regular expressions allow forensics analysts to search through large quantities of text information for patterns of data such as the following: Telephone Numbers Social Security
Excel: Introduction to Formulas
Excel: Introduction to Formulas Table of Contents Formulas Arithmetic & Comparison Operators... 2 Text Concatenation... 2 Operator Precedence... 2 UPPER, LOWER, PROPER and TRIM... 3 & (Ampersand)... 4
3. Add and delete a cover page...7 Add a cover page... 7 Delete a cover page... 7
Microsoft Word: Advanced Features for Publication, Collaboration, and Instruction For your MAC (Word 2011) Presented by: Karen Gray ([email protected]) Word Help: http://mac2.microsoft.com/help/office/14/en-
CS106A, Stanford Handout #38. Strings and Chars
CS106A, Stanford Handout #38 Fall, 2004-05 Nick Parlante Strings and Chars The char type (pronounced "car") represents a single character. A char literal value can be written in the code using single quotes
Retrieving Data Using the SQL SELECT Statement. Copyright 2006, Oracle. All rights reserved.
Retrieving Data Using the SQL SELECT Statement Objectives After completing this lesson, you should be able to do the following: List the capabilities of SQL SELECT statements Execute a basic SELECT statement
Introduction to Python
WEEK ONE Introduction to Python Python is such a simple language to learn that we can throw away the manual and start with an example. Traditionally, the first program to write in any programming language
CS2043 - Unix Tools & Scripting Lecture 9 Shell Scripting
CS2043 - Unix Tools & Scripting Lecture 9 Shell Scripting Spring 2015 1 February 9, 2015 1 based on slides by Hussam Abu-Libdeh, Bruno Abrahao and David Slater over the years Announcements Coursework adjustments
awk A UNIX tool to manipulate and generate formatted data
awk A UNIX tool to manipulate and generate formatted data Alexander Voigt Technische Universität Dresden Institut für Kern- und Teilchenphysik Version_05_21 /01234/546 78994: IKTP Computing Kaffee 10 January
Introduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved.
1 2 Introduction to Java Applications 2.2 First Program in Java: Printing a Line of Text 2 Application Executes when you use the java command to launch the Java Virtual Machine (JVM) Sample program Displays
Lab 9 Access PreLab Copy the prelab folder, Lab09 PreLab9_Access_intro
Lab 9 Access PreLab Copy the prelab folder, Lab09 PreLab9_Access_intro, to your M: drive. To do the second part of the prelab, you will need to have available a database from that folder. Creating a new
HP-UX Essentials and Shell Programming Course Summary
Contact Us: (616) 875-4060 HP-UX Essentials and Shell Programming Course Summary Length: 5 Days Prerequisite: Basic computer skills Recommendation Statement: Student should be able to use a computer monitor,
UNIX, Shell Scripting and Perl Introduction
UNIX, Shell Scripting and Perl Introduction Bart Zeydel 2003 Some useful commands grep searches files for a string. Useful for looking for errors in CAD tool output files. Usage: grep error * (looks for
Command Line - Part 1
Command Line - Part 1 STAT 133 Gaston Sanchez Department of Statistics, UC Berkeley gastonsanchez.com github.com/gastonstat Course web: gastonsanchez.com/teaching/stat133 GUIs 2 Graphical User Interfaces
Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.
Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java
Unix Scripts and Job Scheduling
Unix Scripts and Job Scheduling Michael B. Spring Department of Information Science and Telecommunications University of Pittsburgh [email protected] http://www.sis.pitt.edu/~spring Overview Shell Scripts
Using the Thesis and Dissertation Templates
Using the Thesis and Dissertation Templates For use with Microsoft Word on Windows and Macintosh computers January 2011 Graduate School e-mail: [email protected] 2011 Graduate School Revised January
Introduction to Shell Programming
Introduction to Shell Programming what is shell programming? about cygwin review of basic UNIX TM pipelines of commands about shell scripts some new commands variables parameters and shift command substitution
Kiwi Log Viewer. A Freeware Log Viewer for Windows. by SolarWinds, Inc.
Kiwi Log Viewer A Freeware Log Viewer for Windows by SolarWinds, Inc. Kiwi Log Viewer displays text based log files in a tabular format. Only a small section of the file is read from disk at a time which
PHP Debugging. Draft: March 19, 2013 2013 Christopher Vickery
PHP Debugging Draft: March 19, 2013 2013 Christopher Vickery Introduction Debugging is the art of locating errors in your code. There are three types of errors to deal with: 1. Syntax errors: When code
Regular Expression Syntax
1 of 5 12/22/2014 9:55 AM EmEditor Home - EmEditor Help - How to - Search Regular Expression Syntax EmEditor regular expression syntax is based on Perl regular expression syntax. Literals All characters
BASH Scripting. A bash script may consist of nothing but a series of command lines, e.g. The following helloworld.sh script simply does an echo.
BASH Scripting bash is great for simple scripts that automate things you would otherwise by typing on the command line. Your command line skills will carry over to bash scripting and vice versa. bash comments
Programming Languages CIS 443
Course Objectives Programming Languages CIS 443 0.1 Lexical analysis Syntax Semantics Functional programming Variable lifetime and scoping Parameter passing Object-oriented programming Continuations Exception
USEFUL UNIX COMMANDS
cancel cat file USEFUL UNIX COMMANDS cancel print requested with lp Display the file cat file1 file2 > files Combine file1 and file2 into files cat file1 >> file2 chgrp [options] newgroup files Append
Creating Basic Excel Formulas
Creating Basic Excel Formulas Formulas are equations that perform calculations on values in your worksheet. Depending on how you build a formula in Excel will determine if the answer to your formula automatically
JavaScript: Introduction to Scripting. 2008 Pearson Education, Inc. All rights reserved.
1 6 JavaScript: Introduction to Scripting 2 Comment is free, but facts are sacred. C. P. Scott The creditor hath a better memory than the debtor. James Howell When faced with a decision, I always ask,
Introduction to Shell Scripting
Introduction to Shell Scripting Lecture 1. Shell scripts are small programs. They let you automate multi-step processes, and give you the capability to use decision-making logic and repetitive loops. 2.
VIP Quick Reference Card
VIP Quick Reference Card Loading VIP (Based on VIP 3.5 in GNU Emacs 18) Just type M-x vip-mode followed by RET VIP Modes VIP has three modes: emacs mode, vi mode and insert mode. Mode line tells you which
Microsoft Excel 2010 Part 3: Advanced Excel
CALIFORNIA STATE UNIVERSITY, LOS ANGELES INFORMATION TECHNOLOGY SERVICES Microsoft Excel 2010 Part 3: Advanced Excel Winter 2015, Version 1.0 Table of Contents Introduction...2 Sorting Data...2 Sorting
webmethods Certificate Toolkit
Title Page webmethods Certificate Toolkit User s Guide Version 7.1.1 January 2008 webmethods Copyright & Document ID This document applies to webmethods Certificate Toolkit Version 7.1.1 and to all subsequent
Creating a Simple Macro
28 Creating a Simple Macro What Is a Macro?, 28-2 Terminology: three types of macros The Structure of a Simple Macro, 28-2 GMACRO and ENDMACRO, Template, Body of the macro Example of a Simple Macro, 28-4
Hypercosm. Studio. www.hypercosm.com
Hypercosm Studio www.hypercosm.com Hypercosm Studio Guide 3 Revision: November 2005 Copyright 2005 Hypercosm LLC All rights reserved. Hypercosm, OMAR, Hypercosm 3D Player, and Hypercosm Studio are trademarks
Example of a Java program
Example of a Java program class SomeNumbers static int square (int x) return x*x; public static void main (String[] args) int n=20; if (args.length > 0) // change default n = Integer.parseInt(args[0]);
We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.
LING115 Lecture Note Session #4 Python (1) 1. Introduction As we have seen in previous sessions, we can use Linux shell commands to do simple text processing. We now know, for example, how to count words.
Compilers Lexical Analysis
Compilers Lexical Analysis SITE : http://www.info.univ-tours.fr/ mirian/ TLC - Mírian Halfeld-Ferrari p. 1/3 The Role of the Lexical Analyzer The first phase of a compiler. Lexical analysis : process of
Lab 1: Introduction to C, ASCII ART and the Linux Command Line Environment
.i.-' `-. i..' `/ \' _`.,-../ o o \.' ` ( / \ ) \\\ (_.'.'"`.`._) /// \\`._(..: :..)_.'// \`. \.:-:. /.'/ `-i-->..
Paper 70-27 An Introduction to SAS PROC SQL Timothy J Harrington, Venturi Partners Consulting, Waukegan, Illinois
Paper 70-27 An Introduction to SAS PROC SQL Timothy J Harrington, Venturi Partners Consulting, Waukegan, Illinois Abstract This paper introduces SAS users with at least a basic understanding of SAS data
Computational Mathematics with Python
Computational Mathematics with Python Basics Claus Führer, Jan Erik Solem, Olivier Verdier Spring 2010 Claus Führer, Jan Erik Solem, Olivier Verdier Computational Mathematics with Python Spring 2010 1
Creating a table of contents quickly in Word
Creating a table of contents quickly in Word This note shows you how to set up a table of contents that can be generated and updated quickly and easily, even for the longest and most complex documents.
Install Java Development Kit (JDK) 1.8 http://www.oracle.com/technetwork/java/javase/downloads/index.html
CS 259: Data Structures with Java Hello World with the IntelliJ IDE Instructor: Joel Castellanos e-mail: joel.unm.edu Web: http://cs.unm.edu/~joel/ Office: Farris Engineering Center 319 8/19/2015 Install
Eventia Log Parsing Editor 1.0 Administration Guide
Eventia Log Parsing Editor 1.0 Administration Guide Revised: November 28, 2007 In This Document Overview page 2 Installation and Supported Platforms page 4 Menus and Main Window page 5 Creating Parsing
Select the Crow s Foot entity relationship diagram (ERD) option. Create the entities and define their components.
Α DESIGNING DATABASES WITH VISIO PROFESSIONAL: A TUTORIAL Microsoft Visio Professional is a powerful database design and modeling tool. The Visio software has so many features that we can t possibly demonstrate
Sample Table. Columns. Column 1 Column 2 Column 3 Row 1 Cell 1 Cell 2 Cell 3 Row 2 Cell 4 Cell 5 Cell 6 Row 3 Cell 7 Cell 8 Cell 9.
Working with Tables in Microsoft Word The purpose of this document is to lead you through the steps of creating, editing and deleting tables and parts of tables. This document follows a tutorial format
MATLAB Programming. Problem 1: Sequential
Division of Engineering Fundamentals, Copyright 1999 by J.C. Malzahn Kampe 1 / 21 MATLAB Programming When we use the phrase computer solution, it should be understood that a computer will only follow directions;
Data Tool Platform SQL Development Tools
Data Tool Platform SQL Development Tools ekapner Contents Setting SQL Development Preferences...5 Execution Plan View Options Preferences...5 General Preferences...5 Label Decorations Preferences...6
set in Options). Returns the cursor to its position prior to the Correct command.
Dragon NaturallySpeaking Commands Summary Dragon Productivity Commands Relative to Dragon NaturallySpeaking v11-12 or higher Dragon Medical Practice Edition and Practice Edition 2 or higher Dictation success
Computational Mathematics with Python
Boolean Arrays Classes Computational Mathematics with Python Basics Olivier Verdier and Claus Führer 2009-03-24 Olivier Verdier and Claus Führer Computational Mathematics with Python 2009-03-24 1 / 40
Introduction to Python
Caltech/LEAD Summer 2012 Computer Science Lecture 2: July 10, 2012 Introduction to Python The Python shell Outline Python as a calculator Arithmetic expressions Operator precedence Variables and assignment
Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)
Unit- I Introduction to c Language: C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating
PL / SQL Basics. Chapter 3
PL / SQL Basics Chapter 3 PL / SQL Basics PL / SQL block Lexical units Variable declarations PL / SQL types Expressions and operators PL / SQL control structures PL / SQL style guide 2 PL / SQL Block Basic
Microsoft Word 2010 Basics
Microsoft Word 2010 Basics 1. Start Word if the Word 2007 icon is not on the desktop: a. Click Start>Programs>Microsoft Office>Microsoft Word 2007 b. The Ribbon- seen across the top of Microsoft Word.
Exercise 1: Python Language Basics
Exercise 1: Python Language Basics In this exercise we will cover the basic principles of the Python language. All languages have a standard set of functionality including the ability to comment code,
Microsoft Access 3: Understanding and Creating Queries
Microsoft Access 3: Understanding and Creating Queries In Access Level 2, we learned how to perform basic data retrievals by using Search & Replace functions and Sort & Filter functions. For more complex
PYTHON Basics http://hetland.org/writing/instant-hacking.html
CWCS Workshop May 2009 PYTHON Basics http://hetland.org/writing/instant-hacking.html Python is an easy to learn, modern, interpreted, object-oriented programming language. It was designed to be as simple
3 IDE (Integrated Development Environment)
Visual C++ 6.0 Guide Part I 1 Introduction Microsoft Visual C++ is a software application used to write other applications in C++/C. It is a member of the Microsoft Visual Studio development tools suite,
Unix Sampler. PEOPLE whoami id who
Unix Sampler PEOPLE whoami id who finger username hostname grep pattern /etc/passwd Learn about yourself. See who is logged on Find out about the person who has an account called username on this host
Introduction to the UNIX Operating System and Open Windows Desktop Environment
Introduction to the UNIX Operating System and Open Windows Desktop Environment Welcome to the Unix world! And welcome to the Unity300. As you may have already noticed, there are three Sun Microsystems
ASCII Encoding. The char Type. Manipulating Characters. Manipulating Characters
The char Type ASCII Encoding The C char type stores small integers. It is usually 8 bits. char variables guaranteed to be able to hold integers 0.. +127. char variables mostly used to store characters
Lecture 5: Java Fundamentals III
Lecture 5: Java Fundamentals III School of Science and Technology The University of New England Trimester 2 2015 Lecture 5: Java Fundamentals III - Operators Reading: Finish reading Chapter 2 of the 2nd
Word processing software
Unit 244 Word processing software UAN: Level: 2 Credit value: 4 GLH: 30 Assessment type: Relationship to NOS: Assessment requirements specified by a sector or regulatory body: Aim: R/502/4628 Portfolio
The CDS-ISIS Formatting Language Made Easy
The CDS-ISIS Formatting Language Made Easy Introduction The most complex aspect of CDS-ISIS is the formatting language, used to display, sort, print and download records. The formatting language is very
Q&As: Microsoft Excel 2013: Chapter 2
Q&As: Microsoft Excel 2013: Chapter 2 In Step 5, why did the date that was entered change from 4/5/10 to 4/5/2010? When Excel recognizes that you entered a date in mm/dd/yy format, it automatically formats
Informatica e Sistemi in Tempo Reale
Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)
6.170 Tutorial 3 - Ruby Basics
6.170 Tutorial 3 - Ruby Basics Prerequisites 1. Have Ruby installed on your computer a. If you use Mac/Linux, Ruby should already be preinstalled on your machine. b. If you have a Windows Machine, you
So far we have considered only numeric processing, i.e. processing of numeric data represented
Chapter 4 Processing Character Data So far we have considered only numeric processing, i.e. processing of numeric data represented as integer and oating point types. Humans also use computers to manipulate
Some Scanner Class Methods
Keyboard Input Scanner, Documentation, Style Java 5.0 has reasonable facilities for handling keyboard input. These facilities are provided by the Scanner class in the java.util package. A package is a
Database Programming with PL/SQL: Learning Objectives
Database Programming with PL/SQL: Learning Objectives This course covers PL/SQL, a procedural language extension to SQL. Through an innovative project-based approach, students learn procedural logic constructs
How to Edit Your Website
How to Edit Your Website A guide to using your Content Management System Overview 2 Accessing the CMS 2 Choosing Your Language 2 Resetting Your Password 3 Sites 4 Favorites 4 Pages 5 Creating Pages 5 Managing
How to Write a Simple Makefile
Chapter 1 CHAPTER 1 How to Write a Simple Makefile The mechanics of programming usually follow a fairly simple routine of editing source files, compiling the source into an executable form, and debugging
Shell Scripts (1) For example: #!/bin/sh If they do not, the user's current shell will be used. Any Unix command can go in a shell script
Shell Programming Shell Scripts (1) Basically, a shell script is a text file with Unix commands in it. Shell scripts usually begin with a #! and a shell name For example: #!/bin/sh If they do not, the
Xcode User Default Reference. (Legacy)
Xcode User Default Reference (Legacy) Contents Introduction 5 Organization of This Document 5 Software Version 5 See Also 5 Xcode User Defaults 7 Xcode User Default Overview 7 General User Defaults 8 NSDragAndDropTextDelay
Exercise 4 Learning Python language fundamentals
Exercise 4 Learning Python language fundamentals Work with numbers Python can be used as a powerful calculator. Practicing math calculations in Python will help you not only perform these tasks, but also
VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0
VISUAL GUIDE to RX Scripting for Roulette Xtreme - System Designer 2.0 UX Software - 2009 TABLE OF CONTENTS INTRODUCTION... ii What is this book about?... iii How to use this book... iii Time to start...
CS 241 Data Organization Coding Standards
CS 241 Data Organization Coding Standards Brooke Chenoweth University of New Mexico Spring 2016 CS-241 Coding Standards All projects and labs must follow the great and hallowed CS-241 coding standards.
Introduction to Microsoft Excel 1 Part I
Introduction to Microsoft Excel 1 Part I Objectives When you complete this workshop you will be able to: Recognize Excel s basic operations and tools; Develop simple worksheets; Use formulas; Format worksheets;
The Center for Teaching, Learning, & Technology
The Center for Teaching, Learning, & Technology Instructional Technology Workshops Microsoft Excel 2010 Formulas and Charts Albert Robinson / Delwar Sayeed Faculty and Staff Development Programs Colston
Computational Mathematics with Python
Numerical Analysis, Lund University, 2011 1 Computational Mathematics with Python Chapter 1: Basics Numerical Analysis, Lund University Claus Führer, Jan Erik Solem, Olivier Verdier, Tony Stillfjord Spring
A Programming Language for Mechanical Translation Victor H. Yngve, Massachusetts Institute of Technology, Cambridge, Massachusetts
[Mechanical Translation, vol.5, no.1, July 1958; pp. 25-41] A Programming Language for Mechanical Translation Victor H. Yngve, Massachusetts Institute of Technology, Cambridge, Massachusetts A notational
Python Loops and String Manipulation
WEEK TWO Python Loops and String Manipulation Last week, we showed you some basic Python programming and gave you some intriguing problems to solve. But it is hard to do anything really exciting until
HTML Web Page That Shows Its Own Source Code
HTML Web Page That Shows Its Own Source Code Tom Verhoeff November 2009 1 Introduction A well-known programming challenge is to write a program that prints its own source code. For interpreted languages,
