class: center, middle, inverse, title-slide # Data Science for Economists ## Lecture 3: Learning to love the shell ### Grant McDermott ### University of Oregon |
EC 607
--- name: toc <style type="text/css"> @media print { .has-continuation { display: block !important; } } </style> # Table of contents 1. [Prologue](#prologue) 2. [Introduction](#intro) 3. [Bash shell basics](#basics) 4. [Files and directories](#files) 5. [Working with text files](#text) 6. [Redirecting and pipes](#pipes) 7. [Iteration (for loops)](#iteration) 8. [Scripting](#scripting) 9. [User roles and file permissions](#permissions) 10. [Next steps](#steps) 11. [Appendix (Windows users only)](#windows) --- class: inverse, center, middle name: prologue # Prologue <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> --- # Student presentation: Git GUI As I said in our previous lecture, I think the Git + RStudio (and/or the shell) workflow will be optimal for most of you. But here are some nice standalone Git GUIs that you might want to consider: - [Gitkraken](https://www.gitkraken.com/) - [SourceTree](https://www.sourcetreeapp.com/) - [GitHub Desktop](https://desktop.github.com/) - [Atom](https://github.atom.io/) - [VS Code](https://code.visualstudio.com/docs/introvideos/versioncontrol) --- # Checklist ☑ Have you cloned the [course lecture repo](https://github.com/uo-ec607/lectures) to your local machine? ☑ Once that's done, pull to get the latest lecture slides. ☑ Do you have Bash-compatible shell? (**Windows** users: see [here](#windows) before continuing.) -- </br> I'm also going to recommend that you spruce up your GitHub profiles. - Add your full name, a profile picture, link to website, etc. - No-one wants to work with (or hire) a barcode. -- </br> Today's lecture is the last detour before we get back to data analyis with R and RStudio. - Laying proper foundations with Git and the shell will put us in a strong positon for advanced data science work as the course develops. --- class: inverse, center, middle name: intro # Introduction <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> --- # The Unix philosophy The shell tools that we're going to be using today have their roots in the [Unix](https://en.wikipedia.org/wiki/Unix) family of operating systems originally developed at Bells Labs in the 1970s. Besides paying homage, acknowledging the Unix lineage is important because these tools still embody the "[Unix philosophy](https://en.wikipedia.org/wiki/Unix_philosophy)": > **Do One Thing And Do It Well** -- By pairing and chaining well-designed individual components, we can build powerful and much more complex larger systems. - You can see why the Unix philosophy is also referred to as "minimalist and modular". Again, this philosophy is very clearly expressed in the design and functionality of the Unix shell. --- # Definitions Don't be thrown off by terminology: *shell*, *terminal*, *tty*, *command prompt*, etc. - These are all basically just different names for the same thing.<sup>1</sup> - They are all referring to a **command line interface** (CLI). .footnote[ <sup>1</sup> [Truth be told](https://unix.stackexchange.com/questions/4126/what-is-the-exact-difference-between-a-terminal-a-shell-a-tty-and-a-con), there are some subtle and sometimes important differences, as well as some interesting history behind the names. But we can safely ignore these here. ] -- There are many shell variants, but we're going to focus on [**Bash**](https://www.gnu.org/software/bash/) (i.e. **B**ourne **a**gain **sh**ell). - Included by default on Linux and MacOS. - Windows users need to install a Bash-compatible shell first (again, see [here](#windows)). -- </br> (For the record, I primarily use [zsh](https://ohmyz.sh/) (i.e. the "Z shell") — which is now also the [default shell](https://support.apple.com/en-us/HT208050) on MacOS. As a result, my shell might look slightly different to yours during live coding sessions. The commands will stay the same, though.) --- # Why bother with the shell? 1. Power - Both for executing commands and for fixing problems. There are some things you just can't do in an IDE or GUI. - It also avoids memory complications associated with certain applications and/or IDEs. We'll get to this issue later in the course. 2. Reproducibility - Scripting is reproducible, while clicking is not. 3. Interacting with servers and super computers - The shell is often the only game in town for high performance computing. We'll get to this later in the course. 4. Automating workflow and analysis pipelines - Easily track and reproduce an entire project (e.g. use a Makefile to combine multiple programs, scripts, etc.) -- We're going to focus on 1, 2 and 3 in this course. That's not to say that 4 is unimportant (far from it!), but we just won't have time to cover it. - [Here](https://stat545.com/automation-overview.html), [here](https://books.ropensci.org/drake/index.html), and [here](https://web.stanford.edu/~gentzkow/research/CodeAndData.pdf) are great places to start learning about automation on your own. --- # Things that I use the shell for - Git - Renaming and moving files *en masse* - Finding things on my computer - Combining and manipulating PDFs - Installing and updating software - Scheduling tasks - Monitoring system resources - Connecting to cloud environments - Running analyses ("jobs") on super computers - etc. -- <i> Personal aside: One of the (many) nice things about being a Linux user is that it demystifies the shell. You end up using the shell for various day-to-day operations and so inevitably become very comfortable using it. Every year I manage to convince at least one student to switch... - I recommend [Endeavour OS](https://endeavouros.com/), though [Ubuntu](https://ubuntu.com/) and [Elementary](https://elementary.io/) are good places to start too. </i> --- class: inverse, center, middle name: basics # Bash shell basics <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> --- # First look Let's open up our Bash shell. A convenient way to do this is through [RStudio's built-in Terminal](https://support.rstudio.com/hc/en-us/articles/115010737148-Using-the-RStudio-Terminal). - Hitting `Shift`+`Alt`+`T` will cause a "Terminal" tab to open up in the bottom-left window pane (i.e. next to the "Console" tab). - This should run Bash by default if it is installed on your system. (Windows users: Once again, see [here](#wsl-rstudio).) -- </br> P.S. Of course, it's always possible to open up the Bash shell directly if you prefer. - [Linux](https://www.wikihow.com/Open-a-Terminal-Window-in-Ubuntu) - [Mac](https://www.techwalla.com/articles/how-to-open-terminal-on-a-macbook) - [Windows](https://www.howtogeek.com/265900/everything-you-can-do-with-windows-10s-new-bash-shell/) --- # First look (cont.) You should see something like: ```bash username@hostname:~$ ``` -- This is shell-speak for: "Who am I and where am I?" <!-- - Type in `$ whoami` without the leading dollar sign to confirm. --> --- count: false # First look (cont.) You should see something like: ```bash `username`@hostname:~$ ``` This is shell-speak for: "Who am I and where am I?" - `username` denotes a specific user (one of potentially many on this computer). --- count: false # First look (cont.) You should see something like: ```bash username`@hostname`:~$ ``` This is shell-speak for: "Who am I and where am I?" - `username` denotes a specific user (one of potentially many on this computer). - `@hostname` denotes the name of the computer or server. --- count: false # First look (cont.) You should see something like: ```bash username@hostname`:~`$ ``` This is shell-speak for: "Who am I and where am I?" - `username` denotes a specific user (one of potentially many on this computer). - `@hostname` denotes the name of the computer or server. - `:~` denotes the directory path (where `~` signifies the user's home directory). --- count: false # First look (cont.) You should see something like: ```bash username@hostname:~`$` ``` This is shell-speak for: "Who am I and where am I?" - `username` denotes a specific user (one of potentially many on this computer). - `@hostname` denotes the name of the computer or server. - `:~` denotes the directory path (where `~` signifies the user's home directory). - `$` denotes the start of the command prompt. - We'll get to this later, but for a special "superuser" called root, the dollar sign will change to a `#`. --- # Useful keyboard shortcuts - `Tab` completion. - Use the `↑` (and `↓`) keys to scroll through previous commands. - `Ctrl`+`→` (and `Ctrl`+`←`) to skip whole words at a time. - `Ctrl`+`a` moves the cursor to the beginning of the line. - `Ctrl`+`e` moves the cursor to the end of the line. - `Ctrl`+`k` deletes everything to the right of the cursor. - `Ctrl`+`u` deletes everything to the left of the cursor. - `Ctrl`+`Shift`+`c` to copy and `Ctrl`+`Shift`+`v` to paste. - `clear` to clear your terminal. --- # Syntax All Bash commands have the same basic syntax: **<center>command option(s) argument(s)</center>** Examples: ```bash $ ls -lh ~/Documents/ ``` ```bash $ sort -u myfile.txt ``` --- count: false # Syntax All Bash commands have the same basic syntax: **<center><span style='background: #ffff88;'>command</span> option(s) argument(s)</center>** Examples: ```bash $ `ls` -lh ~/Documents/ ``` ```bash $ `sort` -u myfile.txt ``` --- count: false # Syntax All Bash commands have the same basic syntax: **<center>command <span style='background: #ffff88;'>option(s)</span> argument(s)</center>** Examples: ```bash $ ls `-lh` ~/Documents/ ``` ```bash $ sort `-u` myfile.txt ``` --- count: false # Syntax All Bash commands have the same basic syntax: **<center>command option(s) <span style='background: #ffff88;'>argument(s)</span></center>** Examples: ```bash $ ls -lh `~/Documents/` ``` ```bash $ sort -u `myfile.txt` ``` --- # Syntax All Bash commands have the same basic syntax: **<center>command option(s) argument(s)</center>** Examples: ```bash $ ls -lh ~/Documents/ ``` ```bash $ sort -u myfile.txt ``` </br> **commands** - You don't always need options or arguments. (E.g. `$ ls ~/Documents/` and `$ ls -lh` are both valid commands that will yield output.) - However, you always need a command. --- # Syntax (cont.) **options** (also called **flags**) - Start with a dash. - Usually one letter. - Multiple options can be chained together under a single dash. ```bash $ ls -l -a -h /var/log ## This works $ ls -lah /var/log ## So does this ``` - An exception is with (rarer) options requiring two dashes. ```bash $ ls --group-directories-first --human-readable /var/log ``` **arguments** - Tell the command *what* to operate on. - Usually a file, path, or a set of files and folders. --- # Help: man The `man` command ("manual pages") is your friend if you ever need help. - Tip: Hit spacebar to scroll down a page at a time, "h" to see the help notes of the `man` command itself and "q" to quit. ```bash $ man ls ``` ``` ## LS(1) User Commands LS(1) ## ## NAME ## ls - list directory contents ## ## SYNOPSIS ## ls [OPTION]... [FILE]... ## ## DESCRIPTION ## List information about the FILEs (the current directory by default). ## Sort entries alphabetically if none of -cftuvSUX nor --sort is speci‐ ## fied. ## ## Mandatory arguments to long options are mandatory for short options ## too. ## ## -a, --all ## do not ignore entries starting with . ## ## -A, --almost-all ## do not list implied . and .. ## ## --author ## with -l, print the author of each file ## ## -b, --escape ## print C-style escapes for nongraphic characters ## ## --block-size=SIZE ## with -l, scale sizes by SIZE when printing them; e.g., ## '--block-size=M'; see SIZE format below ## ## -B, --ignore-backups ## do not list implied entries ending with ~ ## ## -c with -lt: sort by, and show, ctime (time of last modification of ## file status information); with -l: show ctime and sort by name; ## otherwise: sort by ctime, newest first ## ## -C list entries by columns ## ## --color[=WHEN] ## colorize the output; WHEN can be 'always' (default if omitted), ## 'auto', or 'never'; more info below ## ## -d, --directory ## list directories themselves, not their contents ## ## -D, --dired ## generate output designed for Emacs' dired mode ## ## -f do not sort, enable -aU, disable -ls --color ## ## -F, --classify ## append indicator (one of */=>@|) to entries ## ## --file-type ## likewise, except do not append '*' ## ## --format=WORD ## across -x, commas -m, horizontal -x, long -l, single-column -1, ## verbose -l, vertical -C ## ## --full-time ## like -l --time-style=full-iso ## ## -g like -l, but do not list owner ## ## --group-directories-first ## group directories before files; ## ## can be augmented with a --sort option, but any use of ## --sort=none (-U) disables grouping ## ## -G, --no-group ## in a long listing, don't print group names ## ## -h, --human-readable ## with -l and -s, print sizes like 1K 234M 2G etc. ## ## --si likewise, but use powers of 1000 not 1024 ## ## -H, --dereference-command-line ## follow symbolic links listed on the command line ## ## --dereference-command-line-symlink-to-dir ## follow each command line symbolic link ## ## that points to a directory ## ## --hide=PATTERN ## do not list implied entries matching shell PATTERN (overridden ## by -a or -A) ## ## --hyperlink[=WHEN] ## hyperlink file names; WHEN can be 'always' (default if omitted), ## 'auto', or 'never' ## ## --indicator-style=WORD ## append indicator with style WORD to entry names: none (default), ## slash (-p), file-type (--file-type), classify (-F) ## ## -i, --inode ## print the index number of each file ## ## -I, --ignore=PATTERN ## do not list implied entries matching shell PATTERN ## ## -k, --kibibytes ## default to 1024-byte blocks for disk usage; used only with -s ## and per directory totals ## ## -l use a long listing format ## ## -L, --dereference ## when showing file information for a symbolic link, show informa‐ ## tion for the file the link references rather than for the link ## itself ## ## -m fill width with a comma separated list of entries ## ## -n, --numeric-uid-gid ## like -l, but list numeric user and group IDs ## ## -N, --literal ## print entry names without quoting ## ## -o like -l, but do not list group information ## ## -p, --indicator-style=slash ## append / indicator to directories ## ## -q, --hide-control-chars ## print ? instead of nongraphic characters ## ## --show-control-chars ## show nongraphic characters as-is (the default, unless program is ## 'ls' and output is a terminal) ## ## -Q, --quote-name ## enclose entry names in double quotes ## ## --quoting-style=WORD ## use quoting style WORD for entry names: literal, locale, shell, ## shell-always, shell-escape, shell-escape-always, c, escape ## (overrides QUOTING_STYLE environment variable) ## ## -r, --reverse ## reverse order while sorting ## ## -R, --recursive ## list subdirectories recursively ## ## -s, --size ## print the allocated size of each file, in blocks ## ## -S sort by file size, largest first ## ## --sort=WORD ## sort by WORD instead of name: none (-U), size (-S), time (-t), ## version (-v), extension (-X) ## ## --time=WORD ## change the default of using modification times; access time ## (-u): atime, access, use; change time (-c): ctime, status; birth ## time: birth, creation; ## ## with -l, WORD determines which time to show; with --sort=time, ## sort by WORD (newest first) ## ## --time-style=TIME_STYLE ## time/date format with -l; see TIME_STYLE below ## ## -t sort by time, newest first; see --time ## ## -T, --tabsize=COLS ## assume tab stops at each COLS instead of 8 ## ## -u with -lt: sort by, and show, access time; with -l: show access ## time and sort by name; otherwise: sort by access time, newest ## first ## ## -U do not sort; list entries in directory order ## ## -v natural sort of (version) numbers within text ## ## -w, --width=COLS ## set output width to COLS. 0 means no limit ## ## -x list entries by lines instead of by columns ## ## -X sort alphabetically by entry extension ## ## -Z, --context ## print any security context of each file ## ## -1 list one file per line. Avoid '\n' with -q or -b ## ## --help display this help and exit ## ## --version ## output version information and exit ## ## The SIZE argument is an integer and optional unit (example: 10K is ## 10*1024). Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... ## (powers of 1000). Binary prefixes can be used, too: KiB=K, MiB=M, and ## so on. ## ## The TIME_STYLE argument can be full-iso, long-iso, iso, locale, or ## +FORMAT. FORMAT is interpreted like in date(1). If FORMAT is FOR‐ ## MAT1<newline>FORMAT2, then FORMAT1 applies to non-recent files and FOR‐ ## MAT2 to recent files. TIME_STYLE prefixed with 'posix-' takes effect ## only outside the POSIX locale. Also the TIME_STYLE environment vari‐ ## able sets the default style to use. ## ## Using color to distinguish file types is disabled both by default and ## with --color=never. With --color=auto, ls emits color codes only when ## standard output is connected to a terminal. The LS_COLORS environment ## variable can change the settings. Use the dircolors command to set it. ## ## Exit status: ## 0 if OK, ## ## 1 if minor problems (e.g., cannot access subdirectory), ## ## 2 if serious trouble (e.g., cannot access command-line argument). ## ## AUTHOR ## Written by Richard M. Stallman and David MacKenzie. ## ## REPORTING BUGS ## GNU coreutils online help: <https://www.gnu.org/software/coreutils/> ## Report any translation bugs to <https://translationproject.org/team/> ## ## COPYRIGHT ## Copyright © 2020 Free Software Foundation, Inc. License GPLv3+: GNU ## GPL version 3 or later <https://gnu.org/licenses/gpl.html>. ## This is free software: you are free to change and redistribute it. ## There is NO WARRANTY, to the extent permitted by law. ## ## SEE ALSO ## Full documentation <https://www.gnu.org/software/coreutils/ls> ## or available locally via: info '(coreutils) ls invocation' ## ## GNU coreutils 8.32 March 2020 LS(1) ``` --- # Help: man (cont.) A useful feature of `man` is quick pattern searching with "/pattern". - Try this now by running `$ man ls` again and then typing "/human" and hitting the return key. - To continue on to the next case, hit `n`. (It won't work here because the pattern "human" only occurs once in the manual file.) -- </br> Again, this and other `man` tricks tricks are detailed in the help pages (hit "h"). --- # Help: cheat I also like the [cheat](https://github.com/chrisallenlane/cheat) utility, which provides a more readable summary / cheatsheet of various command. You'll need to install it first. (Linux and MacOS only.) ``` $ cheat ls ## # Displays everything in the target directory ## ls path/to/the/target/directory ## ## # Displays everything including hidden files ## ls -a ## ## # Displays all files, along with the size (with unit suffixes) and timestamp ## ls -lh ## ## # Display files, sorted by size ## ls -S ## ## # Display directories only ## ls -d */ ## ## # Display directories only, include hidden ## ls -d .*/ */ ``` --- class: inverse, center, middle name: files # Files and directories <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> --- # Navigation Key navigation commands: - `pwd` to print (the current) working directory. - `cd` to change directory. ```bash $ pwd ``` ``` ## /home/grant/Documents/Teaching/EC607/lectures/03-shell ``` -- You can use absolute paths, but it's better to use relative paths and invoke special symbols for a user's home folder (`~`), current directory (`.`), and parent directory (`..`) as needed. ```bash $ cd examples ## Move into the "examples" sub-directory of this lecture directory. $ cd ../.. ## Now go back up two directories. $ pwd ``` ``` ## /home/grant/Documents/Teaching/EC607/lectures ``` --- # Navigation (cont.) Beware of directory names that contain spaces. Say you have a directory called "My Documents". (I'm looking at you, Windows.) - Why won't `$ cd My Documents` work? -- **Answer:** Bash syntax is super pedantic about spaces and ordering. Here it thinks that "My" and "Documents" are separate arguments. -- - Small brain: Use quotation marks: `$ cd "My Documents"`. - Big brain: Use Tab completion to automatically "escape" the space: `$ cd My\ Documents`. - Galaxy brain: Don't use spaces in file and folder names. --- # Navigation (cont.) <div align="center"> <img src="pics/expanding-brain.jpg" alt="Brain" height="550px"/> </div> --- # Listing files and their properties We're about to go into more depth about the `ls` command. - To do this effectively, it will be helpful if we're all working off the same group of files and folders. - Navigate to the directory containing these lecture notes (i.e. `03-shell`). Now list the contents of the `examples/` sub-directory with the `-lh` option ("long format", "human readable"). ```bash $ # cd PathWhereYouClonedThisRepo/lectures/03-shell ## change as needed $ ls -lh examples ``` ``` ## total 148K ## drwxr-xr-x 2 grant users 4.0K May 25 20:30 ABC ## drwxr-xr-x 2 grant users 4.0K Sep 10 2020 Bad folder name ## -rw-r--r-- 1 grant users 149 Feb 24 12:48 hello.R ## -rwxr-xr-x 1 grant users 37 Jan 14 2019 hello.sh ## drwxr-xr-x 2 grant users 4.0K May 25 20:30 meals ## -rw-r--r-- 1 grant users 32 May 25 20:30 nursery.txt ## -rwxrwxrwx 1 grant users 153 Jan 12 2019 reps.txt ## -rw-r--r-- 1 grant users 120K Jan 12 2019 sonnets.txt ``` --- # Listing files and their properties (cont.) What does this all mean? Let's focus on the top line. ```bash drwxr-xr-x 2 grant users 4.0K Jan 12 22:12 ABC ``` --- count:false # Listing files and their properties (cont.) What does this all mean? Let's focus on the top line. <p span style="font-family:Fira Code; font-size:80%; color: #333; background: #f8f8f8; padding: 0.5em;";> <span style='background: #ffff88;'>d</span>rwxr-xr-x 2 grant users 4.0K Jan 12 22:12 ABC</span> - The first column denotes the object type: - `d` (directory or folder), `l` (link), or `-` (file) --- count:false # Listing files and their properties (cont.) What does this all mean? Let's focus on the top line. <p span style="font-family:Fira Code; font-size:80%; color: #333; background: #f8f8f8; padding: 0.5em;";>d<span style='background: #ffff88;'><span style='color: #e41a1c;'>rwx</span><span style='color: #377eb8;'>r-x</span><span style='color: #4daf4a;'>r-x</span></span> 2 grant users 4.0K Jan 12 22:12 ABC</span> - <span style='color: #A9A9A9;'>The first column denotes the object type: - `d` (directory or folder), `l` (link), or `-` (file)</span> - Next, we see the permissions associated with the object's three possible user types: 1) <span style='color: #e41a1c;'>owner</span>, 2) <span style='color: #377eb8;'>the owner's group</span>, and 3) <span style='color: #4daf4a;'>all other users</span>. - Permissions reflect `r` (read), `w` (write), or `x` (execute) access. - <b>`-`</b> denotes missing permissions for a class of operations. --- count:false # Listing files and their properties (cont.) What does this all mean? Let's focus on the top line. <p span style="font-family:Fira Code; font-size:80%; color: #333; background: #f8f8f8; padding: 0.5em;";>drwxr-xr-x <span style='background: #ffff88;'>2</span> grant users 4.0K Jan 12 22:12 ABC</span> - <span style='color: #A9A9A9;'>The first column denotes the object type: - `d` (directory or folder), `l` (link), or `-` (file)</span> - <span style='color: #A9A9A9;'>Next, we see the permissions associated with the object's three possible user types: 1) owner, 2) the owner's group, and 3) all other users. - Permissions reflect `r` (read), `w` (write), or `x` (execute) access. - <b>`-`</b> denotes missing permissions for a class of operations.</span> - The number of [hard links](http://www.giannistsakiris.com/2011/04/15/counting-and-listing-hard-links-on-linux/) to the object. --- count:false # Listing files and their properties (cont.) What does this all mean? Let's focus on the top line. <p span style="font-family:Fira Code; font-size:80%; color: #333; background: #f8f8f8; padding: 0.5em;";>drwxr-xr-x 2 <span style='background: #ffff88;'><span style='color: #e41a1c;'>grant</span> <span style='color: #377eb8;'>users</span></span> 4.0K Jan 12 22:12 ABC</span> - <span style='color: #A9A9A9;'>The first column denotes the object type: - `d` (directory or folder), `l` (link), or `-` (file)</span> - <span style='color: #A9A9A9;'>Next, we see the permissions associated with the object's three possible user types: 1) owner, 2) the owner's group, and 3) all other users. - Permissions reflect `r` (read), `w` (write), or `x` (execute) access. - <b>`-`</b> denotes missing permissions for a class of operations.</span> - <span style='color: #A9A9A9;'>The number of hard links to the object.</span> - We also see the identity of the object's <span style='color: #e41a1c;'>owner</span> and their <span style='color: #377eb8;'>group</span>. --- count:false # Listing files and their properties (cont.) What does this all mean? Let's focus on the top line. <p span style="font-family:Fira Code; font-size:80%; color: #333; background: #f8f8f8; padding: 0.5em;";>drwxr-xr-x 2 grant users <span style='background: #ffff88;'>4.0K Jan 12 22:12 ABC</span></span> - <span style='color: #A9A9A9;'>The first column denotes the object type: - `d` (directory or folder), `l` (link), or `-` (file)</span> - <span style='color: #A9A9A9;'>Next, we see the permissions associated with the object's three possible user types: 1) owner, 2) the owner's group, and 3) all other users. - Permissions reflect `r` (read), `w` (write), or `x` (execute) access. - <b>`-`</b> denotes missing permissions for a class of operations.</span> - <span style='color: #A9A9A9;'>The number of hard links to the object.</span> - <span style='color: #A9A9A9;'>We also see the identity of the object's owner and their group.</span> - Finally, we see some descriptive elements about the object: - Size, date and time of creation, and the object name. --- count:false # Listing files and their properties (cont.) What does this all mean? Let's focus on the top line. ```bash drwxr-xr-x 2 grant users 4.0K Jan 12 22:12 ABC ``` - The first column denotes the object type: - `d` (directory or folder), `l` (link), or `-` (file) - Next, we see the permissions associated with the object's three possible user types: 1) owner, 2) the owner's group, and 3) all other users. - Permissions reflect `r` (read), `w` (write), or `x` (execute) access. - <b>`-`</b> denotes missing permissions for a class of operations. - The number of hard links to the object. - We also see the identity of the object's owner and their group. - Finally, we see some descriptive elements about the object: - Size, date and time of creation, and the object name. </br> Note: We'll return to file permissions and ownership at the end of the lecture. --- # Create: touch and mkdir One of the most common shell tasks is object creation (files, directories, etc.) We use `mkdir` to create directories. E.g. To create a new "testing" directory: ```bash $ mkdir testing ``` We use `touch` to create (empty) files. E.g. To add some files to our new directory: ```bash $ touch testing/test1.txt testing/test2.txt testing/test3.txt ``` -- Check that it worked: ```bash $ ls testing ``` ``` ## test1.txt ## test2.txt ## test3.txt ``` --- # Remove: rm and rmdir Let's delete the objects that we just created. Start with one of the .txt files, by using `rm`. - We could delete all the files at the same time, but you'll see why I want to keep some. ```bash $ rm testing/test1.txt ``` The equivalent command for directories is `rmdir`. ```bash $ rmdir testing ``` ``` ## rmdir: failed to remove 'testing': Directory not empty ``` -- Uh oh... It won't let us delete the directory while it still has files inside of it. The solution is to use the `rm` command again with the "recursive" (`-r` or `-R`) and "force" (`-f`) options. - Excluding the `-f` option is safer, but will trigger a confirmation prompt for every file, which I'd rather avoid here. ```bash $ rm -rf testing ## Success ``` --- # Copy: cp The syntax for copying is `$ cp object path/copyname` - If you don't provide a new name for the copied object, it will just take the old name. - However, if there is already an object with the same name in the target destination, then you'll have to use `-f` to force an overwrite. ```bash $ ## Create new "copies" sub-directory $ mkdir examples/copies $ ## Now copy across a file (with a new name) $ cp examples/reps.txt examples/copies/reps-copy.txt $ ## Show that we were successful $ ls examples/copies ``` ``` ## reps-copy.txt ``` -- You can use `cp` to copy directories, although you'll need the `-r` (or `-R`) flag if you want to recursively copy over everything inside of it to. - Try this by copying over the `meals/` sub-directory to `copies/`. --- # Move (and rename): mv The syntax for moving is `$ mv object path/newobjectname` ```bash $ ## Move the abc.txt file and show that it worked $ mv examples/ABC/abc.txt examples $ ls examples/ABC ## empty ``` ```bash $ ## Move it back again $ mv examples/abc.txt examples/ABC $ ls examples/ABC ## not empty ``` ``` ## abc.txt ``` -- Note that "moving" an object within the same directory, but with the (newobjectname) option, is effectively the same as renaming it. ```bash $ ## Rename reps-copy to reps2 by "moving" it with a new name $ mv examples/copies/reps-copy.txt examples/copies/reps2.txt $ ls examples/copies ``` ``` ## reps2.txt ``` --- # Rename _en masse_: rename Speaking of renaming, a more convenient way to do this is with `rename`. - The syntax is `pattern replacement file(s)` For example, say we want to change the file type (i.e. extension) of a particular file in the `examples/meals` directory. ```bash $ rename csv TXT examples/meals/monday.csv $ ls examples/meals ``` ``` ## friday.csv ## monday.TXT ## saturday.csv ## sunday.csv ## thursday.csv ## tuesday.csv ## wednesday.csv ``` --- # Rename _en masse_: rename (cont.) Where `rename` really shines, however, is in conjunction with regular expressions and wildcards (more on the next slide). - This works especially well for dealing with a whole list of files or folders. For example, let's change _all_ of the file extensions in the `examples/meals` directory. ```bash $ rename csv TXT examples/meals/* $ ls examples/meals ``` ``` ## friday.TXT ## monday.TXT ## saturday.TXT ## sunday.TXT ## thursday.TXT ## tuesday.TXT ## wednesday.TXT ``` -- Better change them back before we continue. (Confirm that this worked for yourself.) ```bash $ rename TXT csv examples/meals/* ``` --- # Wildcards [Wildcards](http://tldp.org/LDP/GNU-Linux-Tools-Summary/html/x11655.htm) are special characters that can be used as a replacement for other characters. The two most important ones are: 1. Replace any number of characters with `*`. - Convenient when you want to copy, move, or delete a whole class of files. ```bash $ cp examples/*.sh examples/copies ## Copy any file with an .sh extension to "copies" $ rm examples/copies/* ## Delete everything in the "copies" directory ``` 2. Replace a single character with `?` - Convenient when you want to discriminate between similarly named files. ```bash $ ls examples/meals/??nday.csv $ ls examples/meals/?onday.csv ``` ``` ## examples/meals/monday.csv ## examples/meals/sunday.csv ## examples/meals/monday.csv ``` ??? We've already seen one wildcard in the form of the backlash (`\`) that was used to escape spaces in file and folder names, e.g. `$ cd My\ Documents`. --- # Find The last command that I want to mention w.r.t. navigation is `find`. - This can be used to locate files and directories based on a variety of criteria; from pattern matching to object properties. ```bash $ find examples -iname "monday.csv" ## will automatically do recursive ``` ``` ## examples/meals/monday.csv ``` ```bash $ find . -iname "*.txt" ## must use "." to indicate pwd ``` ``` ## ./examples/nursery.txt ## ./examples/sonnets.txt ## ./examples/reps.txt ## ./examples/ABC/abc.txt ``` ```bash $ find . -size +100k ## find files larger than 100 KB ``` ``` ## ./examples/sonnets.txt ## ./03-shell.html ## ./03-shell.pdf ## ./pics/wsl-rstudio-2.png ## ./pics/wsl-rstudio-3.png ## ./pics/wsl-rstudio-1.png ## ./pics/wsl-rstudio-4.png ``` --- class: inverse, center, middle name: text # Working with text files <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> --- # Motivation Economists and other (data) scientists spend a lot of time working with text, including scripts, Markdown documents, and delimited text files like CSVs. It therefore makes sense to spend a few slides showing off some Bash shell capabilities for working with text files. - We'll only scratch the surface, but hopefully you'll get an idea of how powerful the shell is in the text domain. --- # Counting text: wc You can use the `wc` command to count: 1) lines of text, 2) the number of words, and 3) the number of characters. Let's demonstrate with a text file containing all of Shakespeare's Sonnets.<sup>1</sup> ```bash $ wc examples/sonnets.txt ``` ``` ## 3029 20701 122780 examples/sonnets.txt ``` .footnote[ <sup>1</sup> Courtesy of [Project Gutenburg](http://www.gutenberg.org/cache/epub/1041/pg1041.txt). ] -- </br> PS — You couldn't tell here, but the character count is actually higher than we'd get if we (bothered) counting by hand, because `wc` counts the invisible newline character "\n". --- # Reading text ### Read everything: cat The simplest way to read in text is with the `cat` ("concatenate") command. Note that `cat` will read in *all* of the text. You can scroll back up in your shell window, but this can still be a pain. Again, let's demonstrate using Shakespeare's Sonnets. (This will overflow the slide.) - I'm also going to use the `-n` flag because I want to show line numbers. -- ```bash $ cat -n examples/sonnets.txt ``` ``` ## 1 The Project Gutenberg EBook of Shakespeare's Sonnets, by William Shakespeare ## 2 ## 3 This eBook is for the use of anyone anywhere at no cost and with ## 4 almost no restrictions whatsoever. You may copy it, give it away or ## 5 re-use it under the terms of the Project Gutenberg License included ## 6 with this eBook or online at www.gutenberg.org ## 7 ## 8 ## 9 Title: Shakespeare's Sonnets ## 10 ## 11 Author: William Shakespeare ## 12 ## 13 Posting Date: April 7, 2014 [EBook #1041] ## 14 Release Date: September, 1997 ## 15 Last Updated: March 10, 2010 ## 16 ## 17 Language: English ## 18 ## 19 ## 20 *** START OF THIS PROJECT GUTENBERG EBOOK SHAKESPEARE'S SONNETS *** ## 21 ## 22 ## 23 ## 24 ## 25 Produced by Joseph S. Miller and Embry-Riddle Aeronautical ## 26 University Library. HTML version by Al Haines. ## 27 ## 28 ## 29 ## 30 ## 31 ## 32 ## 33 ## 34 ## 35 ## 36 ## 37 THE SONNETS ## 38 ## 39 by William Shakespeare ## 40 ## 41 ## 42 ## 43 ## 44 I ## 45 ## 46 From fairest creatures we desire increase, ## 47 That thereby beauty's rose might never die, ## 48 But as the riper should by time decease, ## 49 His tender heir might bear his memory: ## 50 But thou, contracted to thine own bright eyes, ## 51 Feed'st thy light's flame with self-substantial fuel, ## 52 Making a famine where abundance lies, ## 53 Thy self thy foe, to thy sweet self too cruel: ## 54 Thou that art now the world's fresh ornament, ## 55 And only herald to the gaudy spring, ## 56 Within thine own bud buriest thy content, ## 57 And tender churl mak'st waste in niggarding: ## 58 Pity the world, or else this glutton be, ## 59 To eat the world's due, by the grave and thee. ## 60 ## 61 II ## 62 ## 63 When forty winters shall besiege thy brow, ## 64 And dig deep trenches in thy beauty's field, ## 65 Thy youth's proud livery so gazed on now, ## 66 Will be a tatter'd weed of small worth held: ## 67 Then being asked, where all thy beauty lies, ## 68 Where all the treasure of thy lusty days; ## 69 To say, within thine own deep sunken eyes, ## 70 Were an all-eating shame, and thriftless praise. ## 71 How much more praise deserv'd thy beauty's use, ## 72 If thou couldst answer 'This fair child of mine ## 73 Shall sum my count, and make my old excuse,' ## 74 Proving his beauty by succession thine! ## 75 This were to be new made when thou art old, ## 76 And see thy blood warm when thou feel'st it cold. ## 77 ## 78 III ## 79 ## 80 Look in thy glass and tell the face thou viewest ## 81 Now is the time that face should form another; ## 82 Whose fresh repair if now thou not renewest, ## 83 Thou dost beguile the world, unbless some mother. ## 84 For where is she so fair whose unear'd womb ## 85 Disdains the tillage of thy husbandry? ## 86 Or who is he so fond will be the tomb, ## 87 Of his self-love to stop posterity? ## 88 Thou art thy mother's glass and she in thee ## 89 Calls back the lovely April of her prime; ## 90 So thou through windows of thine age shalt see, ## 91 Despite of wrinkles this thy golden time. ## 92 But if thou live, remember'd not to be, ## 93 Die single and thine image dies with thee. ## 94 ## 95 IV ## 96 ## 97 Unthrifty loveliness, why dost thou spend ## 98 Upon thy self thy beauty's legacy? ## 99 Nature's bequest gives nothing, but doth lend, ## 100 And being frank she lends to those are free: ## 101 Then, beauteous niggard, why dost thou abuse ## 102 The bounteous largess given thee to give? ## 103 Profitless usurer, why dost thou use ## 104 So great a sum of sums, yet canst not live? ## 105 For having traffic with thy self alone, ## 106 Thou of thy self thy sweet self dost deceive: ## 107 Then how when nature calls thee to be gone, ## 108 What acceptable audit canst thou leave? ## 109 Thy unused beauty must be tombed with thee, ## 110 Which, used, lives th' executor to be. ## 111 ## 112 V ## 113 ## 114 Those hours, that with gentle work did frame ## 115 The lovely gaze where every eye doth dwell, ## 116 Will play the tyrants to the very same ## 117 And that unfair which fairly doth excel; ## 118 For never-resting time leads summer on ## 119 To hideous winter, and confounds him there; ## 120 Sap checked with frost, and lusty leaves quite gone, ## 121 Beauty o'er-snowed and bareness every where: ## 122 Then were not summer's distillation left, ## 123 A liquid prisoner pent in walls of glass, ## 124 Beauty's effect with beauty were bereft, ## 125 Nor it, nor no remembrance what it was: ## 126 But flowers distill'd, though they with winter meet, ## 127 Leese but their show; their substance still lives sweet. ## 128 ## 129 ## 130 VI ## 131 ## 132 Then let not winter's ragged hand deface, ## 133 In thee thy summer, ere thou be distill'd: ## 134 Make sweet some vial; treasure thou some place ## 135 With beauty's treasure ere it be self-kill'd. ## 136 That use is not forbidden usury, ## 137 Which happies those that pay the willing loan; ## 138 That's for thy self to breed another thee, ## 139 Or ten times happier, be it ten for one; ## 140 Ten times thy self were happier than thou art, ## 141 If ten of thine ten times refigur'd thee: ## 142 Then what could death do if thou shouldst depart, ## 143 Leaving thee living in posterity? ## 144 Be not self-will'd, for thou art much too fair ## 145 To be death's conquest and make worms thine heir. ## 146 ## 147 VII ## 148 ## 149 Lo! in the orient when the gracious light ## 150 Lifts up his burning head, each under eye ## 151 Doth homage to his new-appearing sight, ## 152 Serving with looks his sacred majesty; ## 153 And having climb'd the steep-up heavenly hill, ## 154 Resembling strong youth in his middle age, ## 155 Yet mortal looks adore his beauty still, ## 156 Attending on his golden pilgrimage: ## 157 But when from highmost pitch, with weary car, ## 158 Like feeble age, he reeleth from the day, ## 159 The eyes, 'fore duteous, now converted are ## 160 From his low tract, and look another way: ## 161 So thou, thyself outgoing in thy noon: ## 162 Unlook'd, on diest unless thou get a son. ## 163 ## 164 VIII ## 165 ## 166 Music to hear, why hear'st thou music sadly? ## 167 Sweets with sweets war not, joy delights in joy: ## 168 Why lov'st thou that which thou receiv'st not gladly, ## 169 Or else receiv'st with pleasure thine annoy? ## 170 If the true concord of well-tuned sounds, ## 171 By unions married, do offend thine ear, ## 172 They do but sweetly chide thee, who confounds ## 173 In singleness the parts that thou shouldst bear. ## 174 Mark how one string, sweet husband to another, ## 175 Strikes each in each by mutual ordering; ## 176 Resembling sire and child and happy mother, ## 177 Who, all in one, one pleasing note do sing: ## 178 Whose speechless song being many, seeming one, ## 179 Sings this to thee: 'Thou single wilt prove none.' ## 180 ## 181 IX ## 182 ## 183 Is it for fear to wet a widow's eye, ## 184 That thou consum'st thy self in single life? ## 185 Ah! if thou issueless shalt hap to die, ## 186 The world will wail thee like a makeless wife; ## 187 The world will be thy widow and still weep ## 188 That thou no form of thee hast left behind, ## 189 When every private widow well may keep ## 190 By children's eyes, her husband's shape in mind: ## 191 Look! what an unthrift in the world doth spend ## 192 Shifts but his place, for still the world enjoys it; ## 193 But beauty's waste hath in the world an end, ## 194 And kept unused the user so destroys it. ## 195 No love toward others in that bosom sits ## 196 That on himself such murd'rous shame commits. ## 197 ## 198 X ## 199 ## 200 For shame! deny that thou bear'st love to any, ## 201 Who for thy self art so unprovident. ## 202 Grant, if thou wilt, thou art belov'd of many, ## 203 But that thou none lov'st is most evident: ## 204 For thou art so possess'd with murderous hate, ## 205 That 'gainst thy self thou stick'st not to conspire, ## 206 Seeking that beauteous roof to ruinate ## 207 Which to repair should be thy chief desire. ## 208 O! change thy thought, that I may change my mind: ## 209 Shall hate be fairer lodg'd than gentle love? ## 210 Be, as thy presence is, gracious and kind, ## 211 Or to thyself at least kind-hearted prove: ## 212 Make thee another self for love of me, ## 213 That beauty still may live in thine or thee. ## 214 ## 215 XI ## 216 ## 217 As fast as thou shalt wane, so fast thou grow'st, ## 218 In one of thine, from that which thou departest; ## 219 And that fresh blood which youngly thou bestow'st, ## 220 Thou mayst call thine when thou from youth convertest, ## 221 Herein lives wisdom, beauty, and increase; ## 222 Without this folly, age, and cold decay: ## 223 If all were minded so, the times should cease ## 224 And threescore year would make the world away. ## 225 Let those whom nature hath not made for store, ## 226 Harsh, featureless, and rude, barrenly perish: ## 227 Look, whom she best endow'd, she gave thee more; ## 228 Which bounteous gift thou shouldst in bounty cherish: ## 229 She carv'd thee for her seal, and meant thereby, ## 230 Thou shouldst print more, not let that copy die. ## 231 ## 232 XII ## 233 ## 234 When I do count the clock that tells the time, ## 235 And see the brave day sunk in hideous night; ## 236 When I behold the violet past prime, ## 237 And sable curls, all silvered o'er with white; ## 238 When lofty trees I see barren of leaves, ## 239 Which erst from heat did canopy the herd, ## 240 And summer's green all girded up in sheaves, ## 241 Borne on the bier with white and bristly beard, ## 242 Then of thy beauty do I question make, ## 243 That thou among the wastes of time must go, ## 244 Since sweets and beauties do themselves forsake ## 245 And die as fast as they see others grow; ## 246 And nothing 'gainst Time's scythe can make defence ## 247 Save breed, to brave him when he takes thee hence. ## 248 ## 249 XIII ## 250 ## 251 O! that you were your self; but, love you are ## 252 No longer yours, than you your self here live: ## 253 Against this coming end you should prepare, ## 254 And your sweet semblance to some other give: ## 255 So should that beauty which you hold in lease ## 256 Find no determination; then you were ## 257 Yourself again, after yourself's decease, ## 258 When your sweet issue your sweet form should bear. ## 259 Who lets so fair a house fall to decay, ## 260 Which husbandry in honour might uphold, ## 261 Against the stormy gusts of winter's day ## 262 And barren rage of death's eternal cold? ## 263 O! none but unthrifts. Dear my love, you know, ## 264 You had a father: let your son say so. ## 265 ## 266 XIV ## 267 ## 268 Not from the stars do I my judgement pluck; ## 269 And yet methinks I have astronomy, ## 270 But not to tell of good or evil luck, ## 271 Of plagues, of dearths, or seasons' quality; ## 272 Nor can I fortune to brief minutes tell, ## 273 Pointing to each his thunder, rain and wind, ## 274 Or say with princes if it shall go well ## 275 By oft predict that I in heaven find: ## 276 But from thine eyes my knowledge I derive, ## 277 And constant stars in them I read such art ## 278 As 'Truth and beauty shall together thrive, ## 279 If from thyself, to store thou wouldst convert'; ## 280 Or else of thee this I prognosticate: ## 281 'Thy end is truth's and beauty's doom and date.' ## 282 ## 283 XV ## 284 ## 285 When I consider every thing that grows ## 286 Holds in perfection but a little moment, ## 287 That this huge stage presenteth nought but shows ## 288 Whereon the stars in secret influence comment; ## 289 When I perceive that men as plants increase, ## 290 Cheered and checked even by the self-same sky, ## 291 Vaunt in their youthful sap, at height decrease, ## 292 And wear their brave state out of memory; ## 293 Then the conceit of this inconstant stay ## 294 Sets you most rich in youth before my sight, ## 295 Where wasteful Time debateth with decay ## 296 To change your day of youth to sullied night, ## 297 And all in war with Time for love of you, ## 298 As he takes from you, I engraft you new. ## 299 ## 300 XVI ## 301 ## 302 But wherefore do not you a mightier way ## 303 Make war upon this bloody tyrant, Time? ## 304 And fortify your self in your decay ## 305 With means more blessed than my barren rhyme? ## 306 Now stand you on the top of happy hours, ## 307 And many maiden gardens, yet unset, ## 308 With virtuous wish would bear you living flowers, ## 309 Much liker than your painted counterfeit: ## 310 So should the lines of life that life repair, ## 311 Which this, Time's pencil, or my pupil pen, ## 312 Neither in inward worth nor outward fair, ## 313 Can make you live your self in eyes of men. ## 314 To give away yourself, keeps yourself still, ## 315 And you must live, drawn by your own sweet skill. ## 316 ## 317 XVII ## 318 ## 319 Who will believe my verse in time to come, ## 320 If it were fill'd with your most high deserts? ## 321 Though yet heaven knows it is but as a tomb ## 322 Which hides your life, and shows not half your parts. ## 323 If I could write the beauty of your eyes, ## 324 And in fresh numbers number all your graces, ## 325 The age to come would say 'This poet lies; ## 326 Such heavenly touches ne'er touch'd earthly faces.' ## 327 So should my papers, yellow'd with their age, ## 328 Be scorn'd, like old men of less truth than tongue, ## 329 And your true rights be term'd a poet's rage ## 330 And stretched metre of an antique song: ## 331 But were some child of yours alive that time, ## 332 You should live twice,--in it, and in my rhyme. ## 333 ## 334 XVIII ## 335 ## 336 Shall I compare thee to a summer's day? ## 337 Thou art more lovely and more temperate: ## 338 Rough winds do shake the darling buds of May, ## 339 And summer's lease hath all too short a date: ## 340 Sometime too hot the eye of heaven shines, ## 341 And often is his gold complexion dimm'd, ## 342 And every fair from fair sometime declines, ## 343 By chance, or nature's changing course untrimm'd: ## 344 But thy eternal summer shall not fade, ## 345 Nor lose possession of that fair thou ow'st, ## 346 Nor shall death brag thou wander'st in his shade, ## 347 When in eternal lines to time thou grow'st, ## 348 So long as men can breathe, or eyes can see, ## 349 So long lives this, and this gives life to thee. ## 350 ## 351 XIX ## 352 ## 353 Devouring Time, blunt thou the lion's paws, ## 354 And make the earth devour her own sweet brood; ## 355 Pluck the keen teeth from the fierce tiger's jaws, ## 356 And burn the long-liv'd phoenix, in her blood; ## 357 Make glad and sorry seasons as thou fleets, ## 358 And do whate'er thou wilt, swift-footed Time, ## 359 To the wide world and all her fading sweets; ## 360 But I forbid thee one most heinous crime: ## 361 O! carve not with thy hours my love's fair brow, ## 362 Nor draw no lines there with thine antique pen; ## 363 Him in thy course untainted do allow ## 364 For beauty's pattern to succeeding men. ## 365 Yet, do thy worst old Time: despite thy wrong, ## 366 My love shall in my verse ever live young. ## 367 ## 368 XX ## 369 ## 370 A woman's face with nature's own hand painted, ## 371 Hast thou, the master mistress of my passion; ## 372 A woman's gentle heart, but not acquainted ## 373 With shifting change, as is false women's fashion: ## 374 An eye more bright than theirs, less false in rolling, ## 375 Gilding the object whereupon it gazeth; ## 376 A man in hue all 'hues' in his controlling, ## 377 Which steals men's eyes and women's souls amazeth. ## 378 And for a woman wert thou first created; ## 379 Till Nature, as she wrought thee, fell a-doting, ## 380 And by addition me of thee defeated, ## 381 By adding one thing to my purpose nothing. ## 382 But since she prick'd thee out for women's pleasure, ## 383 Mine be thy love and thy love's use their treasure. ## 384 ## 385 XXI ## 386 ## 387 So is it not with me as with that Muse, ## 388 Stirr'd by a painted beauty to his verse, ## 389 Who heaven itself for ornament doth use ## 390 And every fair with his fair doth rehearse, ## 391 Making a couplement of proud compare. ## 392 With sun and moon, with earth and sea's rich gems, ## 393 With April's first-born flowers, and all things rare, ## 394 That heaven's air in this huge rondure hems. ## 395 O! let me, true in love, but truly write, ## 396 And then believe me, my love is as fair ## 397 As any mother's child, though not so bright ## 398 As those gold candles fix'd in heaven's air: ## 399 Let them say more that like of hearsay well; ## 400 I will not praise that purpose not to sell. ## 401 ## 402 XXII ## 403 ## 404 My glass shall not persuade me I am old, ## 405 So long as youth and thou are of one date; ## 406 But when in thee time's furrows I behold, ## 407 Then look I death my days should expiate. ## 408 For all that beauty that doth cover thee, ## 409 Is but the seemly raiment of my heart, ## 410 Which in thy breast doth live, as thine in me: ## 411 How can I then be elder than thou art? ## 412 O! therefore love, be of thyself so wary ## 413 As I, not for myself, but for thee will; ## 414 Bearing thy heart, which I will keep so chary ## 415 As tender nurse her babe from faring ill. ## 416 Presume not on thy heart when mine is slain, ## 417 Thou gav'st me thine not to give back again. ## 418 ## 419 XXIII ## 420 ## 421 As an unperfect actor on the stage, ## 422 Who with his fear is put beside his part, ## 423 Or some fierce thing replete with too much rage, ## 424 Whose strength's abundance weakens his own heart; ## 425 So I, for fear of trust, forget to say ## 426 The perfect ceremony of love's rite, ## 427 And in mine own love's strength seem to decay, ## 428 O'ercharg'd with burthen of mine own love's might. ## 429 O! let my looks be then the eloquence ## 430 And dumb presagers of my speaking breast, ## 431 Who plead for love, and look for recompense, ## 432 More than that tongue that more hath more express'd. ## 433 O! learn to read what silent love hath writ: ## 434 To hear with eyes belongs to love's fine wit. ## 435 ## 436 XXIV ## 437 ## 438 Mine eye hath play'd the painter and hath stell'd, ## 439 Thy beauty's form in table of my heart; ## 440 My body is the frame wherein 'tis held, ## 441 And perspective it is best painter's art. ## 442 For through the painter must you see his skill, ## 443 To find where your true image pictur'd lies, ## 444 Which in my bosom's shop is hanging still, ## 445 That hath his windows glazed with thine eyes. ## 446 Now see what good turns eyes for eyes have done: ## 447 Mine eyes have drawn thy shape, and thine for me ## 448 Are windows to my breast, where-through the sun ## 449 Delights to peep, to gaze therein on thee; ## 450 Yet eyes this cunning want to grace their art, ## 451 They draw but what they see, know not the heart. ## 452 ## 453 XXV ## 454 ## 455 Let those who are in favour with their stars ## 456 Of public honour and proud titles boast, ## 457 Whilst I, whom fortune of such triumph bars ## 458 Unlook'd for joy in that I honour most. ## 459 Great princes' favourites their fair leaves spread ## 460 But as the marigold at the sun's eye, ## 461 And in themselves their pride lies buried, ## 462 For at a frown they in their glory die. ## 463 The painful warrior famoused for fight, ## 464 After a thousand victories once foil'd, ## 465 Is from the book of honour razed quite, ## 466 And all the rest forgot for which he toil'd: ## 467 Then happy I, that love and am belov'd, ## 468 Where I may not remove nor be remov'd. ## 469 ## 470 XXVI ## 471 ## 472 Lord of my love, to whom in vassalage ## 473 Thy merit hath my duty strongly knit, ## 474 To thee I send this written embassage, ## 475 To witness duty, not to show my wit: ## 476 Duty so great, which wit so poor as mine ## 477 May make seem bare, in wanting words to show it, ## 478 But that I hope some good conceit of thine ## 479 In thy soul's thought, all naked, will bestow it: ## 480 Till whatsoever star that guides my moving, ## 481 Points on me graciously with fair aspect, ## 482 And puts apparel on my tatter'd loving, ## 483 To show me worthy of thy sweet respect: ## 484 Then may I dare to boast how I do love thee; ## 485 Till then, not show my head where thou mayst prove me. ## 486 ## 487 XXVII ## 488 ## 489 Weary with toil, I haste me to my bed, ## 490 The dear respose for limbs with travel tir'd; ## 491 But then begins a journey in my head ## 492 To work my mind, when body's work's expired: ## 493 For then my thoughts--from far where I abide-- ## 494 Intend a zealous pilgrimage to thee, ## 495 And keep my drooping eyelids open wide, ## 496 Looking on darkness which the blind do see: ## 497 Save that my soul's imaginary sight ## 498 Presents thy shadow to my sightless view, ## 499 Which, like a jewel hung in ghastly night, ## 500 Makes black night beauteous, and her old face new. ## 501 Lo! thus, by day my limbs, by night my mind, ## 502 For thee, and for myself, no quiet find. ## 503 ## 504 XXVIII ## 505 ## 506 How can I then return in happy plight, ## 507 That am debarre'd the benefit of rest? ## 508 When day's oppression is not eas'd by night, ## 509 But day by night and night by day oppress'd, ## 510 And each, though enemies to either's reign, ## 511 Do in consent shake hands to torture me, ## 512 The one by toil, the other to complain ## 513 How far I toil, still farther off from thee. ## 514 I tell the day, to please him thou art bright, ## 515 And dost him grace when clouds do blot the heaven: ## 516 So flatter I the swart-complexion'd night, ## 517 When sparkling stars twire not thou gild'st the even. ## 518 But day doth daily draw my sorrows longer, ## 519 And night doth nightly make grief's length seem stronger. ## 520 ## 521 XXIX ## 522 ## 523 When in disgrace with fortune and men's eyes ## 524 I all alone beweep my outcast state, ## 525 And trouble deaf heaven with my bootless cries, ## 526 And look upon myself, and curse my fate, ## 527 Wishing me like to one more rich in hope, ## 528 Featur'd like him, like him with friends possess'd, ## 529 Desiring this man's art, and that man's scope, ## 530 With what I most enjoy contented least; ## 531 Yet in these thoughts my self almost despising, ## 532 Haply I think on thee,-- and then my state, ## 533 Like to the lark at break of day arising ## 534 From sullen earth, sings hymns at heaven's gate; ## 535 For thy sweet love remember'd such wealth brings ## 536 That then I scorn to change my state with kings. ## 537 ## 538 XXX ## 539 ## 540 When to the sessions of sweet silent thought ## 541 I summon up remembrance of things past, ## 542 I sigh the lack of many a thing I sought, ## 543 And with old woes new wail my dear time's waste: ## 544 Then can I drown an eye, unused to flow, ## 545 For precious friends hid in death's dateless night, ## 546 And weep afresh love's long since cancell'd woe, ## 547 And moan the expense of many a vanish'd sight: ## 548 Then can I grieve at grievances foregone, ## 549 And heavily from woe to woe tell o'er ## 550 The sad account of fore-bemoaned moan, ## 551 Which I new pay as if not paid before. ## 552 But if the while I think on thee, dear friend, ## 553 All losses are restor'd and sorrows end. ## 554 ## 555 XXXI ## 556 ## 557 Thy bosom is endeared with all hearts, ## 558 Which I by lacking have supposed dead; ## 559 And there reigns Love, and all Love's loving parts, ## 560 And all those friends which I thought buried. ## 561 How many a holy and obsequious tear ## 562 Hath dear religious love stol'n from mine eye, ## 563 As interest of the dead, which now appear ## 564 But things remov'd that hidden in thee lie! ## 565 Thou art the grave where buried love doth live, ## 566 Hung with the trophies of my lovers gone, ## 567 Who all their parts of me to thee did give, ## 568 That due of many now is thine alone: ## 569 Their images I lov'd, I view in thee, ## 570 And thou--all they--hast all the all of me. ## 571 ## 572 XXXII ## 573 ## 574 If thou survive my well-contented day, ## 575 When that churl Death my bones with dust shall cover ## 576 And shalt by fortune once more re-survey ## 577 These poor rude lines of thy deceased lover, ## 578 Compare them with the bett'ring of the time, ## 579 And though they be outstripp'd by every pen, ## 580 Reserve them for my love, not for their rhyme, ## 581 Exceeded by the height of happier men. ## 582 O! then vouchsafe me but this loving thought: ## 583 'Had my friend's Muse grown with this growing age, ## 584 A dearer birth than this his love had brought, ## 585 To march in ranks of better equipage: ## 586 But since he died and poets better prove, ## 587 Theirs for their style I'll read, his for his love'. ## 588 ## 589 XXXIII ## 590 ## 591 Full many a glorious morning have I seen ## 592 Flatter the mountain tops with sovereign eye, ## 593 Kissing with golden face the meadows green, ## 594 Gilding pale streams with heavenly alchemy; ## 595 Anon permit the basest clouds to ride ## 596 With ugly rack on his celestial face, ## 597 And from the forlorn world his visage hide, ## 598 Stealing unseen to west with this disgrace: ## 599 Even so my sun one early morn did shine, ## 600 With all triumphant splendour on my brow; ## 601 But out! alack! he was but one hour mine, ## 602 The region cloud hath mask'd him from me now. ## 603 Yet him for this my love no whit disdaineth; ## 604 Suns of the world may stain when heaven's sun staineth. ## 605 ## 606 XXXIV ## 607 ## 608 Why didst thou promise such a beauteous day, ## 609 And make me travel forth without my cloak, ## 610 To let base clouds o'ertake me in my way, ## 611 Hiding thy bravery in their rotten smoke? ## 612 'Tis not enough that through the cloud thou break, ## 613 To dry the rain on my storm-beaten face, ## 614 For no man well of such a salve can speak, ## 615 That heals the wound, and cures not the disgrace: ## 616 Nor can thy shame give physic to my grief; ## 617 Though thou repent, yet I have still the loss: ## 618 The offender's sorrow lends but weak relief ## 619 To him that bears the strong offence's cross. ## 620 Ah! but those tears are pearl which thy love sheds, ## 621 And they are rich and ransom all ill deeds. ## 622 ## 623 XXXV ## 624 ## 625 No more be griev'd at that which thou hast done: ## 626 Roses have thorns, and silver fountains mud: ## 627 Clouds and eclipses stain both moon and sun, ## 628 And loathsome canker lives in sweetest bud. ## 629 All men make faults, and even I in this, ## 630 Authorizing thy trespass with compare, ## 631 Myself corrupting, salving thy amiss, ## 632 Excusing thy sins more than thy sins are; ## 633 For to thy sensual fault I bring in sense,-- ## 634 Thy adverse party is thy advocate,-- ## 635 And 'gainst myself a lawful plea commence: ## 636 Such civil war is in my love and hate, ## 637 That I an accessary needs must be, ## 638 To that sweet thief which sourly robs from me. ## 639 ## 640 XXXVI ## 641 ## 642 Let me confess that we two must be twain, ## 643 Although our undivided loves are one: ## 644 So shall those blots that do with me remain, ## 645 Without thy help, by me be borne alone. ## 646 In our two loves there is but one respect, ## 647 Though in our lives a separable spite, ## 648 Which though it alter not love's sole effect, ## 649 Yet doth it steal sweet hours from love's delight. ## 650 I may not evermore acknowledge thee, ## 651 Lest my bewailed guilt should do thee shame, ## 652 Nor thou with public kindness honour me, ## 653 Unless thou take that honour from thy name: ## 654 But do not so, I love thee in such sort, ## 655 As thou being mine, mine is thy good report. ## 656 ## 657 XXXVII ## 658 ## 659 As a decrepit father takes delight ## 660 To see his active child do deeds of youth, ## 661 So I, made lame by Fortune's dearest spite, ## 662 Take all my comfort of thy worth and truth; ## 663 For whether beauty, birth, or wealth, or wit, ## 664 Or any of these all, or all, or more, ## 665 Entitled in thy parts, do crowned sit, ## 666 I make my love engrafted, to this store: ## 667 So then I am not lame, poor, nor despis'd, ## 668 Whilst that this shadow doth such substance give ## 669 That I in thy abundance am suffic'd, ## 670 And by a part of all thy glory live. ## 671 Look what is best, that best I wish in thee: ## 672 This wish I have; then ten times happy me! ## 673 ## 674 XXXVIII ## 675 ## 676 How can my muse want subject to invent, ## 677 While thou dost breathe, that pour'st into my verse ## 678 Thine own sweet argument, too excellent ## 679 For every vulgar paper to rehearse? ## 680 O! give thy self the thanks, if aught in me ## 681 Worthy perusal stand against thy sight; ## 682 For who's so dumb that cannot write to thee, ## 683 When thou thy self dost give invention light? ## 684 Be thou the tenth Muse, ten times more in worth ## 685 Than those old nine which rhymers invocate; ## 686 And he that calls on thee, let him bring forth ## 687 Eternal numbers to outlive long date. ## 688 If my slight muse do please these curious days, ## 689 The pain be mine, but thine shall be the praise. ## 690 ## 691 XXXIX ## 692 ## 693 O! how thy worth with manners may I sing, ## 694 When thou art all the better part of me? ## 695 What can mine own praise to mine own self bring? ## 696 And what is't but mine own when I praise thee? ## 697 Even for this, let us divided live, ## 698 And our dear love lose name of single one, ## 699 That by this separation I may give ## 700 That due to thee which thou deserv'st alone. ## 701 O absence! what a torment wouldst thou prove, ## 702 Were it not thy sour leisure gave sweet leave, ## 703 To entertain the time with thoughts of love, ## 704 Which time and thoughts so sweetly doth deceive, ## 705 And that thou teachest how to make one twain, ## 706 By praising him here who doth hence remain. ## 707 ## 708 XL ## 709 ## 710 Take all my loves, my love, yea take them all; ## 711 What hast thou then more than thou hadst before? ## 712 No love, my love, that thou mayst true love call; ## 713 All mine was thine, before thou hadst this more. ## 714 Then, if for my love, thou my love receivest, ## 715 I cannot blame thee, for my love thou usest; ## 716 But yet be blam'd, if thou thy self deceivest ## 717 By wilful taste of what thyself refusest. ## 718 I do forgive thy robbery, gentle thief, ## 719 Although thou steal thee all my poverty: ## 720 And yet, love knows it is a greater grief ## 721 To bear love's wrong, than hate's known injury. ## 722 Lascivious grace, in whom all ill well shows, ## 723 Kill me with spites yet we must not be foes. ## 724 ## 725 XLI ## 726 ## 727 Those pretty wrongs that liberty commits, ## 728 When I am sometime absent from thy heart, ## 729 Thy beauty, and thy years full well befits, ## 730 For still temptation follows where thou art. ## 731 Gentle thou art, and therefore to be won, ## 732 Beauteous thou art, therefore to be assail'd; ## 733 And when a woman woos, what woman's son ## 734 Will sourly leave her till he have prevail'd? ## 735 Ay me! but yet thou mightst my seat forbear, ## 736 And chide thy beauty and thy straying youth, ## 737 Who lead thee in their riot even there ## 738 Where thou art forced to break a twofold truth:-- ## 739 Hers by thy beauty tempting her to thee, ## 740 Thine by thy beauty being false to me. ## 741 ## 742 XLII ## 743 ## 744 That thou hast her it is not all my grief, ## 745 And yet it may be said I loved her dearly; ## 746 That she hath thee is of my wailing chief, ## 747 A loss in love that touches me more nearly. ## 748 Loving offenders thus I will excuse ye: ## 749 Thou dost love her, because thou know'st I love her; ## 750 And for my sake even so doth she abuse me, ## 751 Suffering my friend for my sake to approve her. ## 752 If I lose thee, my loss is my love's gain, ## 753 And losing her, my friend hath found that loss; ## 754 Both find each other, and I lose both twain, ## 755 And both for my sake lay on me this cross: ## 756 But here's the joy; my friend and I are one; ## 757 Sweet flattery! then she loves but me alone. ## 758 ## 759 XLIII ## 760 ## 761 When most I wink, then do mine eyes best see, ## 762 For all the day they view things unrespected; ## 763 But when I sleep, in dreams they look on thee, ## 764 And darkly bright, are bright in dark directed. ## 765 Then thou, whose shadow shadows doth make bright, ## 766 How would thy shadow's form form happy show ## 767 To the clear day with thy much clearer light, ## 768 When to unseeing eyes thy shade shines so! ## 769 How would, I say, mine eyes be blessed made ## 770 By looking on thee in the living day, ## 771 When in dead night thy fair imperfect shade ## 772 Through heavy sleep on sightless eyes doth stay! ## 773 All days are nights to see till I see thee, ## 774 And nights bright days when dreams do show thee me. ## 775 ## 776 XLIV ## 777 ## 778 If the dull substance of my flesh were thought, ## 779 Injurious distance should not stop my way; ## 780 For then despite of space I would be brought, ## 781 From limits far remote, where thou dost stay. ## 782 No matter then although my foot did stand ## 783 Upon the farthest earth remov'd from thee; ## 784 For nimble thought can jump both sea and land, ## 785 As soon as think the place where he would be. ## 786 But, ah! thought kills me that I am not thought, ## 787 To leap large lengths of miles when thou art gone, ## 788 But that so much of earth and water wrought, ## 789 I must attend time's leisure with my moan; ## 790 Receiving nought by elements so slow ## 791 But heavy tears, badges of either's woe. ## 792 ## 793 XLV ## 794 ## 795 The other two, slight air, and purging fire ## 796 Are both with thee, wherever I abide; ## 797 The first my thought, the other my desire, ## 798 These present-absent with swift motion slide. ## 799 For when these quicker elements are gone ## 800 In tender embassy of love to thee, ## 801 My life, being made of four, with two alone ## 802 Sinks down to death, oppress'd with melancholy; ## 803 Until life's composition be recur'd ## 804 By those swift messengers return'd from thee, ## 805 Who even but now come back again, assur'd, ## 806 Of thy fair health, recounting it to me: ## 807 This told, I joy; but then no longer glad, ## 808 I send them back again, and straight grow sad. ## 809 ## 810 XLVI ## 811 ## 812 Mine eye and heart are at a mortal war, ## 813 How to divide the conquest of thy sight; ## 814 Mine eye my heart thy picture's sight would bar, ## 815 My heart mine eye the freedom of that right. ## 816 My heart doth plead that thou in him dost lie,-- ## 817 A closet never pierc'd with crystal eyes-- ## 818 But the defendant doth that plea deny, ## 819 And says in him thy fair appearance lies. ## 820 To side this title is impannelled ## 821 A quest of thoughts, all tenants to the heart; ## 822 And by their verdict is determined ## 823 The clear eye's moiety, and the dear heart's part: ## 824 As thus; mine eye's due is thy outward part, ## 825 And my heart's right, thy inward love of heart. ## 826 ## 827 XLVII ## 828 ## 829 Betwixt mine eye and heart a league is took, ## 830 And each doth good turns now unto the other: ## 831 When that mine eye is famish'd for a look, ## 832 Or heart in love with sighs himself doth smother, ## 833 With my love's picture then my eye doth feast, ## 834 And to the painted banquet bids my heart; ## 835 Another time mine eye is my heart's guest, ## 836 And in his thoughts of love doth share a part: ## 837 So, either by thy picture or my love, ## 838 Thy self away, art present still with me; ## 839 For thou not farther than my thoughts canst move, ## 840 And I am still with them, and they with thee; ## 841 Or, if they sleep, thy picture in my sight ## 842 Awakes my heart, to heart's and eye's delight. ## 843 ## 844 XLVIII ## 845 ## 846 How careful was I when I took my way, ## 847 Each trifle under truest bars to thrust, ## 848 That to my use it might unused stay ## 849 From hands of falsehood, in sure wards of trust! ## 850 But thou, to whom my jewels trifles are, ## 851 Most worthy comfort, now my greatest grief, ## 852 Thou best of dearest, and mine only care, ## 853 Art left the prey of every vulgar thief. ## 854 Thee have I not lock'd up in any chest, ## 855 Save where thou art not, though I feel thou art, ## 856 Within the gentle closure of my breast, ## 857 From whence at pleasure thou mayst come and part; ## 858 And even thence thou wilt be stol'n I fear, ## 859 For truth proves thievish for a prize so dear. ## 860 ## 861 XLIX ## 862 ## 863 Against that time, if ever that time come, ## 864 When I shall see thee frown on my defects, ## 865 When as thy love hath cast his utmost sum, ## 866 Call'd to that audit by advis'd respects; ## 867 Against that time when thou shalt strangely pass, ## 868 And scarcely greet me with that sun, thine eye, ## 869 When love, converted from the thing it was, ## 870 Shall reasons find of settled gravity; ## 871 Against that time do I ensconce me here, ## 872 Within the knowledge of mine own desert, ## 873 And this my hand, against my self uprear, ## 874 To guard the lawful reasons on thy part: ## 875 To leave poor me thou hast the strength of laws, ## 876 Since why to love I can allege no cause. ## 877 ## 878 L ## 879 ## 880 How heavy do I journey on the way, ## 881 When what I seek, my weary travel's end, ## 882 Doth teach that ease and that repose to say, ## 883 'Thus far the miles are measured from thy friend!' ## 884 The beast that bears me, tired with my woe, ## 885 Plods dully on, to bear that weight in me, ## 886 As if by some instinct the wretch did know ## 887 His rider lov'd not speed, being made from thee: ## 888 The bloody spur cannot provoke him on, ## 889 That sometimes anger thrusts into his hide, ## 890 Which heavily he answers with a groan, ## 891 More sharp to me than spurring to his side; ## 892 For that same groan doth put this in my mind, ## 893 My grief lies onward, and my joy behind. ## 894 ## 895 LI ## 896 ## 897 Thus can my love excuse the slow offence ## 898 Of my dull bearer when from thee I speed: ## 899 From where thou art why should I haste me thence? ## 900 Till I return, of posting is no need. ## 901 O! what excuse will my poor beast then find, ## 902 When swift extremity can seem but slow? ## 903 Then should I spur, though mounted on the wind, ## 904 In winged speed no motion shall I know, ## 905 Then can no horse with my desire keep pace; ## 906 Therefore desire, of perfect'st love being made, ## 907 Shall neigh--no dull flesh--in his fiery race; ## 908 But love, for love, thus shall excuse my jade,-- ## 909 'Since from thee going, he went wilful-slow, ## 910 Towards thee I'll run, and give him leave to go.' ## 911 ## 912 LII ## 913 ## 914 So am I as the rich, whose blessed key, ## 915 Can bring him to his sweet up-locked treasure, ## 916 The which he will not every hour survey, ## 917 For blunting the fine point of seldom pleasure. ## 918 Therefore are feasts so solemn and so rare, ## 919 Since, seldom coming in that long year set, ## 920 Like stones of worth they thinly placed are, ## 921 Or captain jewels in the carcanet. ## 922 So is the time that keeps you as my chest, ## 923 Or as the wardrobe which the robe doth hide, ## 924 To make some special instant special-blest, ## 925 By new unfolding his imprison'd pride. ## 926 Blessed are you whose worthiness gives scope, ## 927 Being had, to triumph; being lacked, to hope. ## 928 ## 929 LIII ## 930 ## 931 What is your substance, whereof are you made, ## 932 That millions of strange shadows on you tend? ## 933 Since every one, hath every one, one shade, ## 934 And you but one, can every shadow lend. ## 935 Describe Adonis, and the counterfeit ## 936 Is poorly imitated after you; ## 937 On Helen's cheek all art of beauty set, ## 938 And you in Grecian tires are painted new: ## 939 Speak of the spring, and foison of the year, ## 940 The one doth shadow of your beauty show, ## 941 The other as your bounty doth appear; ## 942 And you in every blessed shape we know. ## 943 In all external grace you have some part, ## 944 But you like none, none you, for constant heart. ## 945 ## 946 LIV ## 947 ## 948 O! how much more doth beauty beauteous seem ## 949 By that sweet ornament which truth doth give. ## 950 The rose looks fair, but fairer we it deem ## 951 For that sweet odour, which doth in it live. ## 952 The canker blooms have full as deep a dye ## 953 As the perfumed tincture of the roses. ## 954 Hang on such thorns, and play as wantonly ## 955 When summer's breath their masked buds discloses: ## 956 But, for their virtue only is their show, ## 957 They live unwoo'd, and unrespected fade; ## 958 Die to themselves. Sweet roses do not so; ## 959 Of their sweet deaths, are sweetest odours made: ## 960 And so of you, beauteous and lovely youth, ## 961 When that shall vade, by verse distills your truth. ## 962 ## 963 LV ## 964 ## 965 Not marble, nor the gilded monuments ## 966 Of princes, shall outlive this powerful rhyme; ## 967 But you shall shine more bright in these contents ## 968 Than unswept stone, besmear'd with sluttish time. ## 969 When wasteful war shall statues overturn, ## 970 And broils root out the work of masonry, ## 971 Nor Mars his sword, nor war's quick fire shall burn ## 972 The living record of your memory. ## 973 'Gainst death, and all-oblivious enmity ## 974 Shall you pace forth; your praise shall still find room ## 975 Even in the eyes of all posterity ## 976 That wear this world out to the ending doom. ## 977 So, till the judgment that yourself arise, ## 978 You live in this, and dwell in lovers' eyes. ## 979 ## 980 LVI ## 981 ## 982 Sweet love, renew thy force; be it not said ## 983 Thy edge should blunter be than appetite, ## 984 Which but to-day by feeding is allay'd, ## 985 To-morrow sharpened in his former might: ## 986 So, love, be thou, although to-day thou fill ## 987 Thy hungry eyes, even till they wink with fulness, ## 988 To-morrow see again, and do not kill ## 989 The spirit of love, with a perpetual dulness. ## 990 Let this sad interim like the ocean be ## 991 Which parts the shore, where two contracted new ## 992 Come daily to the banks, that when they see ## 993 Return of love, more blest may be the view; ## 994 Or call it winter, which being full of care, ## 995 Makes summer's welcome, thrice more wished, more rare. ## 996 ## 997 LVII ## 998 ## 999 Being your slave what should I do but tend, ## 1000 Upon the hours, and times of your desire? ## 1001 I have no precious time at all to spend; ## 1002 Nor services to do, till you require. ## 1003 Nor dare I chide the world-without-end hour, ## 1004 Whilst I, my sovereign, watch the clock for you, ## 1005 Nor think the bitterness of absence sour, ## 1006 When you have bid your servant once adieu; ## 1007 Nor dare I question with my jealous thought ## 1008 Where you may be, or your affairs suppose, ## 1009 But, like a sad slave, stay and think of nought ## 1010 Save, where you are, how happy you make those. ## 1011 So true a fool is love, that in your will, ## 1012 Though you do anything, he thinks no ill. ## 1013 ## 1014 LVIII ## 1015 ## 1016 That god forbid, that made me first your slave, ## 1017 I should in thought control your times of pleasure, ## 1018 Or at your hand the account of hours to crave, ## 1019 Being your vassal, bound to stay your leisure! ## 1020 O! let me suffer, being at your beck, ## 1021 The imprison'd absence of your liberty; ## 1022 And patience, tame to sufferance, bide each check, ## 1023 Without accusing you of injury. ## 1024 Be where you list, your charter is so strong ## 1025 That you yourself may privilage your time ## 1026 To what you will; to you it doth belong ## 1027 Yourself to pardon of self-doing crime. ## 1028 I am to wait, though waiting so be hell, ## 1029 Not blame your pleasure be it ill or well. ## 1030 ## 1031 LIX ## 1032 ## 1033 If there be nothing new, but that which is ## 1034 Hath been before, how are our brains beguil'd, ## 1035 Which labouring for invention bear amiss ## 1036 The second burthen of a former child! ## 1037 O! that record could with a backward look, ## 1038 Even of five hundred courses of the sun, ## 1039 Show me your image in some antique book, ## 1040 Since mind at first in character was done! ## 1041 That I might see what the old world could say ## 1042 To this composed wonder of your frame; ## 1043 Wh'r we are mended, or wh'r better they, ## 1044 Or whether revolution be the same. ## 1045 O! sure I am the wits of former days, ## 1046 To subjects worse have given admiring praise. ## 1047 ## 1048 LX ## 1049 ## 1050 Like as the waves make towards the pebbled shore, ## 1051 So do our minutes hasten to their end; ## 1052 Each changing place with that which goes before, ## 1053 In sequent toil all forwards do contend. ## 1054 Nativity, once in the main of light, ## 1055 Crawls to maturity, wherewith being crown'd, ## 1056 Crooked eclipses 'gainst his glory fight, ## 1057 And Time that gave doth now his gift confound. ## 1058 Time doth transfix the flourish set on youth ## 1059 And delves the parallels in beauty's brow, ## 1060 Feeds on the rarities of nature's truth, ## 1061 And nothing stands but for his scythe to mow: ## 1062 And yet to times in hope, my verse shall stand. ## 1063 Praising thy worth, despite his cruel hand. ## 1064 ## 1065 LXI ## 1066 ## 1067 Is it thy will, thy image should keep open ## 1068 My heavy eyelids to the weary night? ## 1069 Dost thou desire my slumbers should be broken, ## 1070 While shadows like to thee do mock my sight? ## 1071 Is it thy spirit that thou send'st from thee ## 1072 So far from home into my deeds to pry, ## 1073 To find out shames and idle hours in me, ## 1074 The scope and tenure of thy jealousy? ## 1075 O, no! thy love, though much, is not so great: ## 1076 It is my love that keeps mine eye awake: ## 1077 Mine own true love that doth my rest defeat, ## 1078 To play the watchman ever for thy sake: ## 1079 For thee watch I, whilst thou dost wake elsewhere, ## 1080 From me far off, with others all too near. ## 1081 ## 1082 LXII ## 1083 ## 1084 Sin of self-love possesseth all mine eye ## 1085 And all my soul, and all my every part; ## 1086 And for this sin there is no remedy, ## 1087 It is so grounded inward in my heart. ## 1088 Methinks no face so gracious is as mine, ## 1089 No shape so true, no truth of such account; ## 1090 And for myself mine own worth do define, ## 1091 As I all other in all worths surmount. ## 1092 But when my glass shows me myself indeed ## 1093 Beated and chopp'd with tanned antiquity, ## 1094 Mine own self-love quite contrary I read; ## 1095 Self so self-loving were iniquity. ## 1096 'Tis thee,--myself,--that for myself I praise, ## 1097 Painting my age with beauty of thy days. ## 1098 ## 1099 LXIII ## 1100 ## 1101 Against my love shall be as I am now, ## 1102 With Time's injurious hand crush'd and o'erworn; ## 1103 When hours have drain'd his blood and fill'd his brow ## 1104 With lines and wrinkles; when his youthful morn ## 1105 Hath travell'd on to age's steepy night; ## 1106 And all those beauties whereof now he's king ## 1107 Are vanishing, or vanished out of sight, ## 1108 Stealing away the treasure of his spring; ## 1109 For such a time do I now fortify ## 1110 Against confounding age's cruel knife, ## 1111 That he shall never cut from memory ## 1112 My sweet love's beauty, though my lover's life: ## 1113 His beauty shall in these black lines be seen, ## 1114 And they shall live, and he in them still green. ## 1115 ## 1116 LXIV ## 1117 ## 1118 When I have seen by Time's fell hand defac'd ## 1119 The rich-proud cost of outworn buried age; ## 1120 When sometime lofty towers I see down-raz'd, ## 1121 And brass eternal slave to mortal rage; ## 1122 When I have seen the hungry ocean gain ## 1123 Advantage on the kingdom of the shore, ## 1124 And the firm soil win of the watery main, ## 1125 Increasing store with loss, and loss with store; ## 1126 When I have seen such interchange of state, ## 1127 Or state itself confounded, to decay; ## 1128 Ruin hath taught me thus to ruminate-- ## 1129 That Time will come and take my love away. ## 1130 This thought is as a death which cannot choose ## 1131 But weep to have, that which it fears to lose. ## 1132 ## 1133 LXV ## 1134 ## 1135 Since brass, nor stone, nor earth, nor boundless sea, ## 1136 But sad mortality o'ersways their power, ## 1137 How with this rage shall beauty hold a plea, ## 1138 Whose action is no stronger than a flower? ## 1139 O! how shall summer's honey breath hold out, ## 1140 Against the wrackful siege of battering days, ## 1141 When rocks impregnable are not so stout, ## 1142 Nor gates of steel so strong but Time decays? ## 1143 O fearful meditation! where, alack, ## 1144 Shall Time's best jewel from Time's chest lie hid? ## 1145 Or what strong hand can hold his swift foot back? ## 1146 Or who his spoil of beauty can forbid? ## 1147 O! none, unless this miracle have might, ## 1148 That in black ink my love may still shine bright. ## 1149 ## 1150 LXVI ## 1151 ## 1152 Tired with all these, for restful death I cry, ## 1153 As to behold desert a beggar born, ## 1154 And needy nothing trimm'd in jollity, ## 1155 And purest faith unhappily forsworn, ## 1156 And gilded honour shamefully misplac'd, ## 1157 And maiden virtue rudely strumpeted, ## 1158 And right perfection wrongfully disgrac'd, ## 1159 And strength by limping sway disabled ## 1160 And art made tongue-tied by authority, ## 1161 And folly--doctor-like--controlling skill, ## 1162 And simple truth miscall'd simplicity, ## 1163 And captive good attending captain ill: ## 1164 Tir'd with all these, from these would I be gone, ## 1165 Save that, to die, I leave my love alone. ## 1166 ## 1167 LXVII ## 1168 ## 1169 Ah! wherefore with infection should he live, ## 1170 And with his presence grace impiety, ## 1171 That sin by him advantage should achieve, ## 1172 And lace itself with his society? ## 1173 Why should false painting imitate his cheek, ## 1174 And steel dead seeming of his living hue? ## 1175 Why should poor beauty indirectly seek ## 1176 Roses of shadow, since his rose is true? ## 1177 Why should he live, now Nature bankrupt is, ## 1178 Beggar'd of blood to blush through lively veins? ## 1179 For she hath no exchequer now but his, ## 1180 And proud of many, lives upon his gains. ## 1181 O! him she stores, to show what wealth she had ## 1182 In days long since, before these last so bad. ## 1183 ## 1184 LXVIII ## 1185 ## 1186 Thus is his cheek the map of days outworn, ## 1187 When beauty lived and died as flowers do now, ## 1188 Before these bastard signs of fair were born, ## 1189 Or durst inhabit on a living brow; ## 1190 Before the golden tresses of the dead, ## 1191 The right of sepulchres, were shorn away, ## 1192 To live a second life on second head; ## 1193 Ere beauty's dead fleece made another gay: ## 1194 In him those holy antique hours are seen, ## 1195 Without all ornament, itself and true, ## 1196 Making no summer of another's green, ## 1197 Robbing no old to dress his beauty new; ## 1198 And him as for a map doth Nature store, ## 1199 To show false Art what beauty was of yore. ## 1200 ## 1201 LXIX ## 1202 ## 1203 Those parts of thee that the world's eye doth view ## 1204 Want nothing that the thought of hearts can mend; ## 1205 All tongues--the voice of souls--give thee that due, ## 1206 Uttering bare truth, even so as foes commend. ## 1207 Thy outward thus with outward praise is crown'd; ## 1208 But those same tongues, that give thee so thine own, ## 1209 In other accents do this praise confound ## 1210 By seeing farther than the eye hath shown. ## 1211 They look into the beauty of thy mind, ## 1212 And that in guess they measure by thy deeds; ## 1213 Then--churls--their thoughts, although their eyes were kind, ## 1214 To thy fair flower add the rank smell of weeds: ## 1215 But why thy odour matcheth not thy show, ## 1216 The soil is this, that thou dost common grow. ## 1217 ## 1218 LXX ## 1219 ## 1220 That thou art blam'd shall not be thy defect, ## 1221 For slander's mark was ever yet the fair; ## 1222 The ornament of beauty is suspect, ## 1223 A crow that flies in heaven's sweetest air. ## 1224 So thou be good, slander doth but approve ## 1225 Thy worth the greater being woo'd of time; ## 1226 For canker vice the sweetest buds doth love, ## 1227 And thou present'st a pure unstained prime. ## 1228 Thou hast passed by the ambush of young days ## 1229 Either not assail'd, or victor being charg'd; ## 1230 Yet this thy praise cannot be so thy praise, ## 1231 To tie up envy, evermore enlarg'd, ## 1232 If some suspect of ill mask'd not thy show, ## 1233 Then thou alone kingdoms of hearts shouldst owe. ## 1234 ## 1235 LXXI ## 1236 ## 1237 No longer mourn for me when I am dead ## 1238 Than you shall hear the surly sullen bell ## 1239 Give warning to the world that I am fled ## 1240 From this vile world with vilest worms to dwell: ## 1241 Nay, if you read this line, remember not ## 1242 The hand that writ it, for I love you so, ## 1243 That I in your sweet thoughts would be forgot, ## 1244 If thinking on me then should make you woe. ## 1245 O! if,--I say you look upon this verse, ## 1246 When I perhaps compounded am with clay, ## 1247 Do not so much as my poor name rehearse; ## 1248 But let your love even with my life decay; ## 1249 Lest the wise world should look into your moan, ## 1250 And mock you with me after I am gone. ## 1251 ## 1252 LXXII ## 1253 ## 1254 O! lest the world should task you to recite ## 1255 What merit lived in me, that you should love ## 1256 After my death,--dear love, forget me quite, ## 1257 For you in me can nothing worthy prove; ## 1258 Unless you would devise some virtuous lie, ## 1259 To do more for me than mine own desert, ## 1260 And hang more praise upon deceased I ## 1261 Than niggard truth would willingly impart: ## 1262 O! lest your true love may seem false in this ## 1263 That you for love speak well of me untrue, ## 1264 My name be buried where my body is, ## 1265 And live no more to shame nor me nor you. ## 1266 For I am shamed by that which I bring forth, ## 1267 And so should you, to love things nothing worth. ## 1268 ## 1269 LXXIII ## 1270 ## 1271 That time of year thou mayst in me behold ## 1272 When yellow leaves, or none, or few, do hang ## 1273 Upon those boughs which shake against the cold, ## 1274 Bare ruin'd choirs, where late the sweet birds sang. ## 1275 In me thou see'st the twilight of such day ## 1276 As after sunset fadeth in the west; ## 1277 Which by and by black night doth take away, ## 1278 Death's second self, that seals up all in rest. ## 1279 In me thou see'st the glowing of such fire, ## 1280 That on the ashes of his youth doth lie, ## 1281 As the death-bed, whereon it must expire, ## 1282 Consum'd with that which it was nourish'd by. ## 1283 This thou perceiv'st, which makes thy love more strong, ## 1284 To love that well, which thou must leave ere long. ## 1285 ## 1286 LXXIV ## 1287 ## 1288 But be contented: when that fell arrest ## 1289 Without all bail shall carry me away, ## 1290 My life hath in this line some interest, ## 1291 Which for memorial still with thee shall stay. ## 1292 When thou reviewest this, thou dost review ## 1293 The very part was consecrate to thee: ## 1294 The earth can have but earth, which is his due; ## 1295 My spirit is thine, the better part of me: ## 1296 So then thou hast but lost the dregs of life, ## 1297 The prey of worms, my body being dead; ## 1298 The coward conquest of a wretch's knife, ## 1299 Too base of thee to be remembered. ## 1300 The worth of that is that which it contains, ## 1301 And that is this, and this with thee remains. ## 1302 ## 1303 LXXV ## 1304 ## 1305 So are you to my thoughts as food to life, ## 1306 Or as sweet-season'd showers are to the ground; ## 1307 And for the peace of you I hold such strife ## 1308 As 'twixt a miser and his wealth is found. ## 1309 Now proud as an enjoyer, and anon ## 1310 Doubting the filching age will steal his treasure; ## 1311 Now counting best to be with you alone, ## 1312 Then better'd that the world may see my pleasure: ## 1313 Sometime all full with feasting on your sight, ## 1314 And by and by clean starved for a look; ## 1315 Possessing or pursuing no delight, ## 1316 Save what is had, or must from you be took. ## 1317 Thus do I pine and surfeit day by day, ## 1318 Or gluttoning on all, or all away. ## 1319 ## 1320 LXXVI ## 1321 ## 1322 Why is my verse so barren of new pride, ## 1323 So far from variation or quick change? ## 1324 Why with the time do I not glance aside ## 1325 To new-found methods, and to compounds strange? ## 1326 Why write I still all one, ever the same, ## 1327 And keep invention in a noted weed, ## 1328 That every word doth almost tell my name, ## 1329 Showing their birth, and where they did proceed? ## 1330 O! know sweet love I always write of you, ## 1331 And you and love are still my argument; ## 1332 So all my best is dressing old words new, ## 1333 Spending again what is already spent: ## 1334 For as the sun is daily new and old, ## 1335 So is my love still telling what is told. ## 1336 ## 1337 LXXVII ## 1338 ## 1339 Thy glass will show thee how thy beauties wear, ## 1340 Thy dial how thy precious minutes waste; ## 1341 These vacant leaves thy mind's imprint will bear, ## 1342 And of this book, this learning mayst thou taste. ## 1343 The wrinkles which thy glass will truly show ## 1344 Of mouthed graves will give thee memory; ## 1345 Thou by thy dial's shady stealth mayst know ## 1346 Time's thievish progress to eternity. ## 1347 Look! what thy memory cannot contain, ## 1348 Commit to these waste blanks, and thou shalt find ## 1349 Those children nursed, deliver'd from thy brain, ## 1350 To take a new acquaintance of thy mind. ## 1351 These offices, so oft as thou wilt look, ## 1352 Shall profit thee and much enrich thy book. ## 1353 ## 1354 LXXVIII ## 1355 ## 1356 So oft have I invoked thee for my Muse, ## 1357 And found such fair assistance in my verse ## 1358 As every alien pen hath got my use ## 1359 And under thee their poesy disperse. ## 1360 Thine eyes, that taught the dumb on high to sing ## 1361 And heavy ignorance aloft to fly, ## 1362 Have added feathers to the learned's wing ## 1363 And given grace a double majesty. ## 1364 Yet be most proud of that which I compile, ## 1365 Whose influence is thine, and born of thee: ## 1366 In others' works thou dost but mend the style, ## 1367 And arts with thy sweet graces graced be; ## 1368 But thou art all my art, and dost advance ## 1369 As high as learning, my rude ignorance. ## 1370 ## 1371 LXXIX ## 1372 ## 1373 Whilst I alone did call upon thy aid, ## 1374 My verse alone had all thy gentle grace; ## 1375 But now my gracious numbers are decay'd, ## 1376 And my sick Muse doth give an other place. ## 1377 I grant, sweet love, thy lovely argument ## 1378 Deserves the travail of a worthier pen; ## 1379 Yet what of thee thy poet doth invent ## 1380 He robs thee of, and pays it thee again. ## 1381 He lends thee virtue, and he stole that word ## 1382 From thy behaviour; beauty doth he give, ## 1383 And found it in thy cheek: he can afford ## 1384 No praise to thee, but what in thee doth live. ## 1385 Then thank him not for that which he doth say, ## 1386 Since what he owes thee, thou thyself dost pay. ## 1387 ## 1388 LXXX ## 1389 ## 1390 O! how I faint when I of you do write, ## 1391 Knowing a better spirit doth use your name, ## 1392 And in the praise thereof spends all his might, ## 1393 To make me tongue-tied speaking of your fame! ## 1394 But since your worth--wide as the ocean is,-- ## 1395 The humble as the proudest sail doth bear, ## 1396 My saucy bark, inferior far to his, ## 1397 On your broad main doth wilfully appear. ## 1398 Your shallowest help will hold me up afloat, ## 1399 Whilst he upon your soundless deep doth ride; ## 1400 Or, being wrack'd, I am a worthless boat, ## 1401 He of tall building, and of goodly pride: ## 1402 Then if he thrive and I be cast away, ## 1403 The worst was this,--my love was my decay. ## 1404 ## 1405 LXXXI ## 1406 ## 1407 Or I shall live your epitaph to make, ## 1408 Or you survive when I in earth am rotten; ## 1409 From hence your memory death cannot take, ## 1410 Although in me each part will be forgotten. ## 1411 Your name from hence immortal life shall have, ## 1412 Though I, once gone, to all the world must die: ## 1413 The earth can yield me but a common grave, ## 1414 When you entombed in men's eyes shall lie. ## 1415 Your monument shall be my gentle verse, ## 1416 Which eyes not yet created shall o'er-read; ## 1417 And tongues to be, your being shall rehearse, ## 1418 When all the breathers of this world are dead; ## 1419 You still shall live,--such virtue hath my pen,-- ## 1420 Where breath most breathes, even in the mouths of men. ## 1421 ## 1422 LXXXII ## 1423 ## 1424 I grant thou wert not married to my Muse, ## 1425 And therefore mayst without attaint o'erlook ## 1426 The dedicated words which writers use ## 1427 Of their fair subject, blessing every book. ## 1428 Thou art as fair in knowledge as in hue, ## 1429 Finding thy worth a limit past my praise; ## 1430 And therefore art enforced to seek anew ## 1431 Some fresher stamp of the time-bettering days. ## 1432 And do so, love; yet when they have devis'd, ## 1433 What strained touches rhetoric can lend, ## 1434 Thou truly fair, wert truly sympathiz'd ## 1435 In true plain words, by thy true-telling friend; ## 1436 And their gross painting might be better us'd ## 1437 Where cheeks need blood; in thee it is abus'd. ## 1438 ## 1439 LXXXIII ## 1440 ## 1441 I never saw that you did painting need, ## 1442 And therefore to your fair no painting set; ## 1443 I found, or thought I found, you did exceed ## 1444 That barren tender of a poet's debt: ## 1445 And therefore have I slept in your report, ## 1446 That you yourself, being extant, well might show ## 1447 How far a modern quill doth come too short, ## 1448 Speaking of worth, what worth in you doth grow. ## 1449 This silence for my sin you did impute, ## 1450 Which shall be most my glory being dumb; ## 1451 For I impair not beauty being mute, ## 1452 When others would give life, and bring a tomb. ## 1453 There lives more life in one of your fair eyes ## 1454 Than both your poets can in praise devise. ## 1455 ## 1456 LXXXIV ## 1457 ## 1458 Who is it that says most, which can say more, ## 1459 Than this rich praise,--that you alone, are you? ## 1460 In whose confine immured is the store ## 1461 Which should example where your equal grew. ## 1462 Lean penury within that pen doth dwell ## 1463 That to his subject lends not some small glory; ## 1464 But he that writes of you, if he can tell ## 1465 That you are you, so dignifies his story, ## 1466 Let him but copy what in you is writ, ## 1467 Not making worse what nature made so clear, ## 1468 And such a counterpart shall fame his wit, ## 1469 Making his style admired every where. ## 1470 You to your beauteous blessings add a curse, ## 1471 Being fond on praise, which makes your praises worse. ## 1472 ## 1473 LXXXV ## 1474 ## 1475 My tongue-tied Muse in manners holds her still, ## 1476 While comments of your praise richly compil'd, ## 1477 Reserve their character with golden quill, ## 1478 And precious phrase by all the Muses fil'd. ## 1479 I think good thoughts, whilst others write good words, ## 1480 And like unlettered clerk still cry 'Amen' ## 1481 To every hymn that able spirit affords, ## 1482 In polish'd form of well-refined pen. ## 1483 Hearing you praised, I say ''tis so, 'tis true,' ## 1484 And to the most of praise add something more; ## 1485 But that is in my thought, whose love to you, ## 1486 Though words come hindmost, holds his rank before. ## 1487 Then others, for the breath of words respect, ## 1488 Me for my dumb thoughts, speaking in effect. ## 1489 ## 1490 LXXXVI ## 1491 ## 1492 Was it the proud full sail of his great verse, ## 1493 Bound for the prize of all too precious you, ## 1494 That did my ripe thoughts in my brain inhearse, ## 1495 Making their tomb the womb wherein they grew? ## 1496 Was it his spirit, by spirits taught to write, ## 1497 Above a mortal pitch, that struck me dead? ## 1498 No, neither he, nor his compeers by night ## 1499 Giving him aid, my verse astonished. ## 1500 He, nor that affable familiar ghost ## 1501 Which nightly gulls him with intelligence, ## 1502 As victors of my silence cannot boast; ## 1503 I was not sick of any fear from thence: ## 1504 But when your countenance fill'd up his line, ## 1505 Then lacked I matter; that enfeebled mine. ## 1506 ## 1507 LXXXVII ## 1508 ## 1509 Farewell! thou art too dear for my possessing, ## 1510 And like enough thou know'st thy estimate, ## 1511 The charter of thy worth gives thee releasing; ## 1512 My bonds in thee are all determinate. ## 1513 For how do I hold thee but by thy granting? ## 1514 And for that riches where is my deserving? ## 1515 The cause of this fair gift in me is wanting, ## 1516 And so my patent back again is swerving. ## 1517 Thy self thou gav'st, thy own worth then not knowing, ## 1518 Or me to whom thou gav'st it, else mistaking; ## 1519 So thy great gift, upon misprision growing, ## 1520 Comes home again, on better judgement making. ## 1521 Thus have I had thee, as a dream doth flatter, ## 1522 In sleep a king, but waking no such matter. ## 1523 ## 1524 LXXXVIII ## 1525 ## 1526 When thou shalt be dispos'd to set me light, ## 1527 And place my merit in the eye of scorn, ## 1528 Upon thy side, against myself I'll fight, ## 1529 And prove thee virtuous, though thou art forsworn. ## 1530 With mine own weakness, being best acquainted, ## 1531 Upon thy part I can set down a story ## 1532 Of faults conceal'd, wherein I am attainted; ## 1533 That thou in losing me shalt win much glory: ## 1534 And I by this will be a gainer too; ## 1535 For bending all my loving thoughts on thee, ## 1536 The injuries that to myself I do, ## 1537 Doing thee vantage, double-vantage me. ## 1538 Such is my love, to thee I so belong, ## 1539 That for thy right, myself will bear all wrong. ## 1540 ## 1541 LXXXIX ## 1542 ## 1543 Say that thou didst forsake me for some fault, ## 1544 And I will comment upon that offence: ## 1545 Speak of my lameness, and I straight will halt, ## 1546 Against thy reasons making no defence. ## 1547 Thou canst not love disgrace me half so ill, ## 1548 To set a form upon desired change, ## 1549 As I'll myself disgrace; knowing thy will, ## 1550 I will acquaintance strangle, and look strange; ## 1551 Be absent from thy walks; and in my tongue ## 1552 Thy sweet beloved name no more shall dwell, ## 1553 Lest I, too much profane, should do it wrong, ## 1554 And haply of our old acquaintance tell. ## 1555 For thee, against my self I'll vow debate, ## 1556 For I must ne'er love him whom thou dost hate. ## 1557 ## 1558 XC ## 1559 ## 1560 Then hate me when thou wilt; if ever, now; ## 1561 Now, while the world is bent my deeds to cross, ## 1562 Join with the spite of fortune, make me bow, ## 1563 And do not drop in for an after-loss: ## 1564 Ah! do not, when my heart hath 'scap'd this sorrow, ## 1565 Come in the rearward of a conquer'd woe; ## 1566 Give not a windy night a rainy morrow, ## 1567 To linger out a purpos'd overthrow. ## 1568 If thou wilt leave me, do not leave me last, ## 1569 When other petty griefs have done their spite, ## 1570 But in the onset come: so shall I taste ## 1571 At first the very worst of fortune's might; ## 1572 And other strains of woe, which now seem woe, ## 1573 Compar'd with loss of thee, will not seem so. ## 1574 ## 1575 XCI ## 1576 ## 1577 Some glory in their birth, some in their skill, ## 1578 Some in their wealth, some in their body's force, ## 1579 Some in their garments though new-fangled ill; ## 1580 Some in their hawks and hounds, some in their horse; ## 1581 And every humour hath his adjunct pleasure, ## 1582 Wherein it finds a joy above the rest: ## 1583 But these particulars are not my measure, ## 1584 All these I better in one general best. ## 1585 Thy love is better than high birth to me, ## 1586 Richer than wealth, prouder than garments' costs, ## 1587 Of more delight than hawks and horses be; ## 1588 And having thee, of all men's pride I boast: ## 1589 Wretched in this alone, that thou mayst take ## 1590 All this away, and me most wretchcd make. ## 1591 ## 1592 XCII ## 1593 ## 1594 But do thy worst to steal thyself away, ## 1595 For term of life thou art assured mine; ## 1596 And life no longer than thy love will stay, ## 1597 For it depends upon that love of thine. ## 1598 Then need I not to fear the worst of wrongs, ## 1599 When in the least of them my life hath end. ## 1600 I see a better state to me belongs ## 1601 Than that which on thy humour doth depend: ## 1602 Thou canst not vex me with inconstant mind, ## 1603 Since that my life on thy revolt doth lie. ## 1604 O! what a happy title do I find, ## 1605 Happy to have thy love, happy to die! ## 1606 But what's so blessed-fair that fears no blot? ## 1607 Thou mayst be false, and yet I know it not. ## 1608 ## 1609 XCIII ## 1610 ## 1611 So shall I live, supposing thou art true, ## 1612 Like a deceived husband; so love's face ## 1613 May still seem love to me, though alter'd new; ## 1614 Thy looks with me, thy heart in other place: ## 1615 For there can live no hatred in thine eye, ## 1616 Therefore in that I cannot know thy change. ## 1617 In many's looks, the false heart's history ## 1618 Is writ in moods, and frowns, and wrinkles strange. ## 1619 But heaven in thy creation did decree ## 1620 That in thy face sweet love should ever dwell; ## 1621 Whate'er thy thoughts, or thy heart's workings be, ## 1622 Thy looks should nothing thence, but sweetness tell. ## 1623 How like Eve's apple doth thy beauty grow, ## 1624 If thy sweet virtue answer not thy show! ## 1625 ## 1626 XCIV ## 1627 ## 1628 They that have power to hurt, and will do none, ## 1629 That do not do the thing they most do show, ## 1630 Who, moving others, are themselves as stone, ## 1631 Unmoved, cold, and to temptation slow; ## 1632 They rightly do inherit heaven's graces, ## 1633 And husband nature's riches from expense; ## 1634 They are the lords and owners of their faces, ## 1635 Others, but stewards of their excellence. ## 1636 The summer's flower is to the summer sweet, ## 1637 Though to itself, it only live and die, ## 1638 But if that flower with base infection meet, ## 1639 The basest weed outbraves his dignity: ## 1640 For sweetest things turn sourest by their deeds; ## 1641 Lilies that fester, smell far worse than weeds. ## 1642 ## 1643 XCV ## 1644 ## 1645 How sweet and lovely dost thou make the shame ## 1646 Which, like a canker in the fragrant rose, ## 1647 Doth spot the beauty of thy budding name! ## 1648 O! in what sweets dost thou thy sins enclose. ## 1649 That tongue that tells the story of thy days, ## 1650 Making lascivious comments on thy sport, ## 1651 Cannot dispraise, but in a kind of praise; ## 1652 Naming thy name, blesses an ill report. ## 1653 O! what a mansion have those vices got ## 1654 Which for their habitation chose out thee, ## 1655 Where beauty's veil doth cover every blot ## 1656 And all things turns to fair that eyes can see! ## 1657 Take heed, dear heart, of this large privilege; ## 1658 The hardest knife ill-us'd doth lose his edge. ## 1659 ## 1660 XCVI ## 1661 ## 1662 Some say thy fault is youth, some wantonness; ## 1663 Some say thy grace is youth and gentle sport; ## 1664 Both grace and faults are lov'd of more and less: ## 1665 Thou mak'st faults graces that to thee resort. ## 1666 As on the finger of a throned queen ## 1667 The basest jewel will be well esteem'd, ## 1668 So are those errors that in thee are seen ## 1669 To truths translated, and for true things deem'd. ## 1670 How many lambs might the stern wolf betray, ## 1671 If like a lamb he could his looks translate! ## 1672 How many gazers mightst thou lead away, ## 1673 if thou wouldst use the strength of all thy state! ## 1674 But do not so; I love thee in such sort, ## 1675 As, thou being mine, mine is thy good report. ## 1676 ## 1677 XCVII ## 1678 ## 1679 How like a winter hath my absence been ## 1680 From thee, the pleasure of the fleeting year! ## 1681 What freezings have I felt, what dark days seen! ## 1682 What old December's bareness everywhere! ## 1683 And yet this time removed was summer's time; ## 1684 The teeming autumn, big with rich increase, ## 1685 Bearing the wanton burden of the prime, ## 1686 Like widow'd wombs after their lords' decease: ## 1687 Yet this abundant issue seem'd to me ## 1688 But hope of orphans, and unfather'd fruit; ## 1689 For summer and his pleasures wait on thee, ## 1690 And, thou away, the very birds are mute: ## 1691 Or, if they sing, 'tis with so dull a cheer, ## 1692 That leaves look pale, dreading the winter's near. ## 1693 ## 1694 XCVIII ## 1695 ## 1696 From you have I been absent in the spring, ## 1697 When proud-pied April, dress'd in all his trim, ## 1698 Hath put a spirit of youth in every thing, ## 1699 That heavy Saturn laugh'd and leap'd with him. ## 1700 Yet nor the lays of birds, nor the sweet smell ## 1701 Of different flowers in odour and in hue, ## 1702 Could make me any summer's story tell, ## 1703 Or from their proud lap pluck them where they grew: ## 1704 Nor did I wonder at the lily's white, ## 1705 Nor praise the deep vermilion in the rose; ## 1706 They were but sweet, but figures of delight, ## 1707 Drawn after you, you pattern of all those. ## 1708 Yet seem'd it winter still, and you away, ## 1709 As with your shadow I with these did play. ## 1710 ## 1711 XCIX ## 1712 ## 1713 The forward violet thus did I chide: ## 1714 Sweet thief, whence didst thou steal thy sweet that smells, ## 1715 If not from my love's breath? The purple pride ## 1716 Which on thy soft cheek for complexion dwells ## 1717 In my love's veins thou hast too grossly dy'd. ## 1718 The lily I condemned for thy hand, ## 1719 And buds of marjoram had stol'n thy hair; ## 1720 The roses fearfully on thorns did stand, ## 1721 One blushing shame, another white despair; ## 1722 A third, nor red nor white, had stol'n of both, ## 1723 And to his robbery had annex'd thy breath; ## 1724 But, for his theft, in pride of all his growth ## 1725 A vengeful canker eat him up to death. ## 1726 More flowers I noted, yet I none could see, ## 1727 But sweet, or colour it had stol'n from thee. ## 1728 ## 1729 C ## 1730 ## 1731 Where art thou Muse that thou forget'st so long, ## 1732 To speak of that which gives thee all thy might? ## 1733 Spend'st thou thy fury on some worthless song, ## 1734 Darkening thy power to lend base subjects light? ## 1735 Return forgetful Muse, and straight redeem, ## 1736 In gentle numbers time so idly spent; ## 1737 Sing to the ear that doth thy lays esteem ## 1738 And gives thy pen both skill and argument. ## 1739 Rise, resty Muse, my love's sweet face survey, ## 1740 If Time have any wrinkle graven there; ## 1741 If any, be a satire to decay, ## 1742 And make time's spoils despised every where. ## 1743 Give my love fame faster than Time wastes life, ## 1744 So thou prevent'st his scythe and crooked knife. ## 1745 ## 1746 CI ## 1747 ## 1748 O truant Muse what shall be thy amends ## 1749 For thy neglect of truth in beauty dy'd? ## 1750 Both truth and beauty on my love depends; ## 1751 So dost thou too, and therein dignified. ## 1752 Make answer Muse: wilt thou not haply say, ## 1753 'Truth needs no colour, with his colour fix'd; ## 1754 Beauty no pencil, beauty's truth to lay; ## 1755 But best is best, if never intermix'd'? ## 1756 Because he needs no praise, wilt thou be dumb? ## 1757 Excuse not silence so, for't lies in thee ## 1758 To make him much outlive a gilded tomb ## 1759 And to be prais'd of ages yet to be. ## 1760 Then do thy office, Muse; I teach thee how ## 1761 To make him seem long hence as he shows now. ## 1762 ## 1763 CII ## 1764 ## 1765 My love is strengthen'd, though more weak in seeming; ## 1766 I love not less, though less the show appear; ## 1767 That love is merchandiz'd, whose rich esteeming, ## 1768 The owner's tongue doth publish every where. ## 1769 Our love was new, and then but in the spring, ## 1770 When I was wont to greet it with my lays; ## 1771 As Philomel in summer's front doth sing, ## 1772 And stops her pipe in growth of riper days: ## 1773 Not that the summer is less pleasant now ## 1774 Than when her mournful hymns did hush the night, ## 1775 But that wild music burthens every bough, ## 1776 And sweets grown common lose their dear delight. ## 1777 Therefore like her, I sometime hold my tongue: ## 1778 Because I would not dull you with my song. ## 1779 ## 1780 CIII ## 1781 ## 1782 Alack! what poverty my Muse brings forth, ## 1783 That having such a scope to show her pride, ## 1784 The argument, all bare, is of more worth ## 1785 Than when it hath my added praise beside! ## 1786 O! blame me not, if I no more can write! ## 1787 Look in your glass, and there appears a face ## 1788 That over-goes my blunt invention quite, ## 1789 Dulling my lines, and doing me disgrace. ## 1790 Were it not sinful then, striving to mend, ## 1791 To mar the subject that before was well? ## 1792 For to no other pass my verses tend ## 1793 Than of your graces and your gifts to tell; ## 1794 And more, much more, than in my verse can sit, ## 1795 Your own glass shows you when you look in it. ## 1796 ## 1797 CIV ## 1798 ## 1799 To me, fair friend, you never can be old, ## 1800 For as you were when first your eye I ey'd, ## 1801 Such seems your beauty still. Three winters cold, ## 1802 Have from the forests shook three summers' pride, ## 1803 Three beauteous springs to yellow autumn turn'd, ## 1804 In process of the seasons have I seen, ## 1805 Three April perfumes in three hot Junes burn'd, ## 1806 Since first I saw you fresh, which yet are green. ## 1807 Ah! yet doth beauty like a dial-hand, ## 1808 Steal from his figure, and no pace perceiv'd; ## 1809 So your sweet hue, which methinks still doth stand, ## 1810 Hath motion, and mine eye may be deceiv'd: ## 1811 For fear of which, hear this thou age unbred: ## 1812 Ere you were born was beauty's summer dead. ## 1813 ## 1814 CV ## 1815 ## 1816 Let not my love be call'd idolatry, ## 1817 Nor my beloved as an idol show, ## 1818 Since all alike my songs and praises be ## 1819 To one, of one, still such, and ever so. ## 1820 Kind is my love to-day, to-morrow kind, ## 1821 Still constant in a wondrous excellence; ## 1822 Therefore my verse to constancy confin'd, ## 1823 One thing expressing, leaves out difference. ## 1824 'Fair, kind, and true,' is all my argument, ## 1825 'Fair, kind, and true,' varying to other words; ## 1826 And in this change is my invention spent, ## 1827 Three themes in one, which wondrous scope affords. ## 1828 Fair, kind, and true, have often liv'd alone, ## 1829 Which three till now, never kept seat in one. ## 1830 ## 1831 CVI ## 1832 ## 1833 When in the chronicle of wasted time ## 1834 I see descriptions of the fairest wights, ## 1835 And beauty making beautiful old rime, ## 1836 In praise of ladies dead and lovely knights, ## 1837 Then, in the blazon of sweet beauty's best, ## 1838 Of hand, of foot, of lip, of eye, of brow, ## 1839 I see their antique pen would have express'd ## 1840 Even such a beauty as you master now. ## 1841 So all their praises are but prophecies ## 1842 Of this our time, all you prefiguring; ## 1843 And for they looked but with divining eyes, ## 1844 They had not skill enough your worth to sing: ## 1845 For we, which now behold these present days, ## 1846 Have eyes to wonder, but lack tongues to praise. ## 1847 ## 1848 CVII ## 1849 ## 1850 Not mine own fears, nor the prophetic soul ## 1851 Of the wide world dreaming on things to come, ## 1852 Can yet the lease of my true love control, ## 1853 Supposed as forfeit to a confin'd doom. ## 1854 The mortal moon hath her eclipse endur'd, ## 1855 And the sad augurs mock their own presage; ## 1856 Incertainties now crown themselves assur'd, ## 1857 And peace proclaims olives of endless age. ## 1858 Now with the drops of this most balmy time, ## 1859 My love looks fresh, and Death to me subscribes, ## 1860 Since, spite of him, I'll live in this poor rime, ## 1861 While he insults o'er dull and speechless tribes: ## 1862 And thou in this shalt find thy monument, ## 1863 When tyrants' crests and tombs of brass are spent. ## 1864 ## 1865 CVIII ## 1866 ## 1867 What's in the brain, that ink may character, ## 1868 Which hath not figur'd to thee my true spirit? ## 1869 What's new to speak, what now to register, ## 1870 That may express my love, or thy dear merit? ## 1871 Nothing, sweet boy; but yet, like prayers divine, ## 1872 I must each day say o'er the very same; ## 1873 Counting no old thing old, thou mine, I thine, ## 1874 Even as when first I hallow'd thy fair name. ## 1875 So that eternal love in love's fresh case, ## 1876 Weighs not the dust and injury of age, ## 1877 Nor gives to necessary wrinkles place, ## 1878 But makes antiquity for aye his page; ## 1879 Finding the first conceit of love there bred, ## 1880 Where time and outward form would show it dead. ## 1881 ## 1882 CIX ## 1883 ## 1884 O! never say that I was false of heart, ## 1885 Though absence seem'd my flame to qualify, ## 1886 As easy might I from my self depart ## 1887 As from my soul which in thy breast doth lie: ## 1888 That is my home of love: if I have rang'd, ## 1889 Like him that travels, I return again; ## 1890 Just to the time, not with the time exchang'd, ## 1891 So that myself bring water for my stain. ## 1892 Never believe though in my nature reign'd, ## 1893 All frailties that besiege all kinds of blood, ## 1894 That it could so preposterously be stain'd, ## 1895 To leave for nothing all thy sum of good; ## 1896 For nothing this wide universe I call, ## 1897 Save thou, my rose, in it thou art my all. ## 1898 ## 1899 CX ## 1900 ## 1901 Alas! 'tis true, I have gone here and there, ## 1902 And made my self a motley to the view, ## 1903 Gor'd mine own thoughts, sold cheap what is most dear, ## 1904 Made old offences of affections new; ## 1905 Most true it is, that I have look'd on truth ## 1906 Askance and strangely; but, by all above, ## 1907 These blenches gave my heart another youth, ## 1908 And worse essays prov'd thee my best of love. ## 1909 Now all is done, save what shall have no end: ## 1910 Mine appetite I never more will grind ## 1911 On newer proof, to try an older friend, ## 1912 A god in love, to whom I am confin'd. ## 1913 Then give me welcome, next my heaven the best, ## 1914 Even to thy pure and most most loving breast. ## 1915 ## 1916 CXI ## 1917 ## 1918 O! for my sake do you with Fortune chide, ## 1919 The guilty goddess of my harmful deeds, ## 1920 That did not better for my life provide ## 1921 Than public means which public manners breeds. ## 1922 Thence comes it that my name receives a brand, ## 1923 And almost thence my nature is subdu'd ## 1924 To what it works in, like the dyer's hand: ## 1925 Pity me, then, and wish I were renew'd; ## 1926 Whilst, like a willing patient, I will drink, ## 1927 Potions of eisel 'gainst my strong infection; ## 1928 No bitterness that I will bitter think, ## 1929 Nor double penance, to correct correction. ## 1930 Pity me then, dear friend, and I assure ye, ## 1931 Even that your pity is enough to cure me. ## 1932 ## 1933 CXII ## 1934 ## 1935 Your love and pity doth the impression fill, ## 1936 Which vulgar scandal stamp'd upon my brow; ## 1937 For what care I who calls me well or ill, ## 1938 So you o'er-green my bad, my good allow? ## 1939 You are my all-the-world, and I must strive ## 1940 To know my shames and praises from your tongue; ## 1941 None else to me, nor I to none alive, ## 1942 That my steel'd sense or changes right or wrong. ## 1943 In so profound abysm I throw all care ## 1944 Of others' voices, that my adder's sense ## 1945 To critic and to flatterer stopped are. ## 1946 Mark how with my neglect I do dispense: ## 1947 You are so strongly in my purpose bred, ## 1948 That all the world besides methinks are dead. ## 1949 ## 1950 CXIII ## 1951 ## 1952 Since I left you, mine eye is in my mind; ## 1953 And that which governs me to go about ## 1954 Doth part his function and is partly blind, ## 1955 Seems seeing, but effectually is out; ## 1956 For it no form delivers to the heart ## 1957 Of bird, of flower, or shape which it doth latch: ## 1958 Of his quick objects hath the mind no part, ## 1959 Nor his own vision holds what it doth catch; ## 1960 For if it see the rud'st or gentlest sight, ## 1961 The most sweet favour or deformed'st creature, ## 1962 The mountain or the sea, the day or night: ## 1963 The crow, or dove, it shapes them to your feature. ## 1964 Incapable of more, replete with you, ## 1965 My most true mind thus maketh mine untrue. ## 1966 ## 1967 CXIV ## 1968 ## 1969 Or whether doth my mind, being crown'd with you, ## 1970 Drink up the monarch's plague, this flattery? ## 1971 Or whether shall I say, mine eye saith true, ## 1972 And that your love taught it this alchemy, ## 1973 To make of monsters and things indigest ## 1974 Such cherubins as your sweet self resemble, ## 1975 Creating every bad a perfect best, ## 1976 As fast as objects to his beams assemble? ## 1977 O! 'tis the first, 'tis flattery in my seeing, ## 1978 And my great mind most kingly drinks it up: ## 1979 Mine eye well knows what with his gust is 'greeing, ## 1980 And to his palate doth prepare the cup: ## 1981 If it be poison'd, 'tis the lesser sin ## 1982 That mine eye loves it and doth first begin. ## 1983 ## 1984 CXV ## 1985 ## 1986 Those lines that I before have writ do lie, ## 1987 Even those that said I could not love you dearer: ## 1988 Yet then my judgment knew no reason why ## 1989 My most full flame should afterwards burn clearer. ## 1990 But reckoning Time, whose million'd accidents ## 1991 Creep in 'twixt vows, and change decrees of kings, ## 1992 Tan sacred beauty, blunt the sharp'st intents, ## 1993 Divert strong minds to the course of altering things; ## 1994 Alas! why fearing of Time's tyranny, ## 1995 Might I not then say, 'Now I love you best,' ## 1996 When I was certain o'er incertainty, ## 1997 Crowning the present, doubting of the rest? ## 1998 Love is a babe, then might I not say so, ## 1999 To give full growth to that which still doth grow? ## 2000 ## 2001 CXVI ## 2002 ## 2003 Let me not to the marriage of true minds ## 2004 Admit impediments. Love is not love ## 2005 Which alters when it alteration finds, ## 2006 Or bends with the remover to remove: ## 2007 O, no! it is an ever-fixed mark, ## 2008 That looks on tempests and is never shaken; ## 2009 It is the star to every wandering bark, ## 2010 Whose worth's unknown, although his height be taken. ## 2011 Love's not Time's fool, though rosy lips and cheeks ## 2012 Within his bending sickle's compass come; ## 2013 Love alters not with his brief hours and weeks, ## 2014 But bears it out even to the edge of doom. ## 2015 If this be error and upon me prov'd, ## 2016 I never writ, nor no man ever lov'd. ## 2017 ## 2018 CXVII ## 2019 ## 2020 Accuse me thus: that I have scanted all, ## 2021 Wherein I should your great deserts repay, ## 2022 Forgot upon your dearest love to call, ## 2023 Whereto all bonds do tie me day by day; ## 2024 That I have frequent been with unknown minds, ## 2025 And given to time your own dear-purchas'd right; ## 2026 That I have hoisted sail to all the winds ## 2027 Which should transport me farthest from your sight. ## 2028 Book both my wilfulness and errors down, ## 2029 And on just proof surmise, accumulate; ## 2030 Bring me within the level of your frown, ## 2031 But shoot not at me in your waken'd hate; ## 2032 Since my appeal says I did strive to prove ## 2033 The constancy and virtue of your love. ## 2034 ## 2035 CXVIII ## 2036 ## 2037 Like as, to make our appetite more keen, ## 2038 With eager compounds we our palate urge; ## 2039 As, to prevent our maladies unseen, ## 2040 We sicken to shun sickness when we purge; ## 2041 Even so, being full of your ne'er-cloying sweetness, ## 2042 To bitter sauces did I frame my feeding; ## 2043 And, sick of welfare, found a kind of meetness ## 2044 To be diseas'd, ere that there was true needing. ## 2045 Thus policy in love, to anticipate ## 2046 The ills that were not, grew to faults assur'd, ## 2047 And brought to medicine a healthful state ## 2048 Which, rank of goodness, would by ill be cur'd; ## 2049 But thence I learn and find the lesson true, ## 2050 Drugs poison him that so fell sick of you. ## 2051 ## 2052 CXIX ## 2053 ## 2054 What potions have I drunk of Siren tears, ## 2055 Distill'd from limbecks foul as hell within, ## 2056 Applying fears to hopes, and hopes to fears, ## 2057 Still losing when I saw myself to win! ## 2058 What wretched errors hath my heart committed, ## 2059 Whilst it hath thought itself so blessed never! ## 2060 How have mine eyes out of their spheres been fitted, ## 2061 In the distraction of this madding fever! ## 2062 O benefit of ill! now I find true ## 2063 That better is, by evil still made better; ## 2064 And ruin'd love, when it is built anew, ## 2065 Grows fairer than at first, more strong, far greater. ## 2066 So I return rebuk'd to my content, ## 2067 And gain by ill thrice more than I have spent. ## 2068 ## 2069 CXX ## 2070 ## 2071 That you were once unkind befriends me now, ## 2072 And for that sorrow, which I then did feel, ## 2073 Needs must I under my transgression bow, ## 2074 Unless my nerves were brass or hammer'd steel. ## 2075 For if you were by my unkindness shaken, ## 2076 As I by yours, you've pass'd a hell of time; ## 2077 And I, a tyrant, have no leisure taken ## 2078 To weigh how once I suffer'd in your crime. ## 2079 O! that our night of woe might have remember'd ## 2080 My deepest sense, how hard true sorrow hits, ## 2081 And soon to you, as you to me, then tender'd ## 2082 The humble salve, which wounded bosoms fits! ## 2083 But that your trespass now becomes a fee; ## 2084 Mine ransoms yours, and yours must ransom me. ## 2085 ## 2086 CXXI ## 2087 ## 2088 'Tis better to be vile than vile esteem'd, ## 2089 When not to be receives reproach of being; ## 2090 And the just pleasure lost, which is so deem'd ## 2091 Not by our feeling, but by others' seeing: ## 2092 For why should others' false adulterate eyes ## 2093 Give salutation to my sportive blood? ## 2094 Or on my frailties why are frailer spies, ## 2095 Which in their wills count bad what I think good? ## 2096 No, I am that I am, and they that level ## 2097 At my abuses reckon up their own: ## 2098 I may be straight though they themselves be bevel; ## 2099 By their rank thoughts, my deeds must not be shown; ## 2100 Unless this general evil they maintain, ## 2101 All men are bad and in their badness reign. ## 2102 ## 2103 CXXII ## 2104 ## 2105 Thy gift, thy tables, are within my brain ## 2106 Full character'd with lasting memory, ## 2107 Which shall above that idle rank remain, ## 2108 Beyond all date; even to eternity: ## 2109 Or, at the least, so long as brain and heart ## 2110 Have faculty by nature to subsist; ## 2111 Till each to raz'd oblivion yield his part ## 2112 Of thee, thy record never can be miss'd. ## 2113 That poor retention could not so much hold, ## 2114 Nor need I tallies thy dear love to score; ## 2115 Therefore to give them from me was I bold, ## 2116 To trust those tables that receive thee more: ## 2117 To keep an adjunct to remember thee ## 2118 Were to import forgetfulness in me. ## 2119 ## 2120 CXXIII ## 2121 ## 2122 No, Time, thou shalt not boast that I do change: ## 2123 Thy pyramids built up with newer might ## 2124 To me are nothing novel, nothing strange; ## 2125 They are but dressings of a former sight. ## 2126 Our dates are brief, and therefore we admire ## 2127 What thou dost foist upon us that is old; ## 2128 And rather make them born to our desire ## 2129 Than think that we before have heard them told. ## 2130 Thy registers and thee I both defy, ## 2131 Not wondering at the present nor the past, ## 2132 For thy records and what we see doth lie, ## 2133 Made more or less by thy continual haste. ## 2134 This I do vow and this shall ever be; ## 2135 I will be true despite thy scythe and thee. ## 2136 ## 2137 CXXIV ## 2138 ## 2139 If my dear love were but the child of state, ## 2140 It might for Fortune's bastard be unfather'd, ## 2141 As subject to Time's love or to Time's hate, ## 2142 Weeds among weeds, or flowers with flowers gather'd. ## 2143 No, it was builded far from accident; ## 2144 It suffers not in smiling pomp, nor falls ## 2145 Under the blow of thralled discontent, ## 2146 Whereto th' inviting time our fashion calls: ## 2147 It fears not policy, that heretic, ## 2148 Which works on leases of short-number'd hours, ## 2149 But all alone stands hugely politic, ## 2150 That it nor grows with heat, nor drowns with showers. ## 2151 To this I witness call the fools of time, ## 2152 Which die for goodness, who have lived for crime. ## 2153 ## 2154 CXXV ## 2155 ## 2156 Were't aught to me I bore the canopy, ## 2157 With my extern the outward honouring, ## 2158 Or laid great bases for eternity, ## 2159 Which proves more short than waste or ruining? ## 2160 Have I not seen dwellers on form and favour ## 2161 Lose all and more by paying too much rent ## 2162 For compound sweet; forgoing simple savour, ## 2163 Pitiful thrivers, in their gazing spent? ## 2164 No; let me be obsequious in thy heart, ## 2165 And take thou my oblation, poor but free, ## 2166 Which is not mix'd with seconds, knows no art, ## 2167 But mutual render, only me for thee. ## 2168 Hence, thou suborned informer! a true soul ## 2169 When most impeach'd, stands least in thy control. ## 2170 ## 2171 CXXVI ## 2172 ## 2173 O thou, my lovely boy, who in thy power ## 2174 Dost hold Time's fickle glass, his fickle hour; ## 2175 Who hast by waning grown, and therein show'st ## 2176 Thy lovers withering, as thy sweet self grow'st. ## 2177 If Nature, sovereign mistress over wrack, ## 2178 As thou goest onwards, still will pluck thee back, ## 2179 She keeps thee to this purpose, that her skill ## 2180 May time disgrace and wretched minutes kill. ## 2181 Yet fear her, O thou minion of her pleasure! ## 2182 She may detain, but not still keep, her treasure: ## 2183 Her audit (though delayed) answered must be, ## 2184 And her quietus is to render thee. ## 2185 ## 2186 CXXVII ## 2187 ## 2188 In the old age black was not counted fair, ## 2189 Or if it were, it bore not beauty's name; ## 2190 But now is black beauty's successive heir, ## 2191 And beauty slander'd with a bastard shame: ## 2192 For since each hand hath put on Nature's power, ## 2193 Fairing the foul with Art's false borrowed face, ## 2194 Sweet beauty hath no name, no holy bower, ## 2195 But is profan'd, if not lives in disgrace. ## 2196 Therefore my mistress' eyes are raven black, ## 2197 Her eyes so suited, and they mourners seem ## 2198 At such who, not born fair, no beauty lack, ## 2199 Sland'ring creation with a false esteem: ## 2200 Yet so they mourn becoming of their woe, ## 2201 That every tongue says beauty should look so. ## 2202 ## 2203 CXXVIII ## 2204 ## 2205 How oft when thou, my music, music play'st, ## 2206 Upon that blessed wood whose motion sounds ## 2207 With thy sweet fingers when thou gently sway'st ## 2208 The wiry concord that mine ear confounds, ## 2209 Do I envy those jacks that nimble leap, ## 2210 To kiss the tender inward of thy hand, ## 2211 Whilst my poor lips which should that harvest reap, ## 2212 At the wood's boldness by thee blushing stand! ## 2213 To be so tickled, they would change their state ## 2214 And situation with those dancing chips, ## 2215 O'er whom thy fingers walk with gentle gait, ## 2216 Making dead wood more bless'd than living lips. ## 2217 Since saucy jacks so happy are in this, ## 2218 Give them thy fingers, me thy lips to kiss. ## 2219 ## 2220 CXXIX ## 2221 ## 2222 The expense of spirit in a waste of shame ## 2223 Is lust in action: and till action, lust ## 2224 Is perjur'd, murderous, bloody, full of blame, ## 2225 Savage, extreme, rude, cruel, not to trust; ## 2226 Enjoy'd no sooner but despised straight; ## 2227 Past reason hunted; and no sooner had, ## 2228 Past reason hated, as a swallow'd bait, ## 2229 On purpose laid to make the taker mad: ## 2230 Mad in pursuit and in possession so; ## 2231 Had, having, and in quest, to have extreme; ## 2232 A bliss in proof,-- and prov'd, a very woe; ## 2233 Before, a joy propos'd; behind a dream. ## 2234 All this the world well knows; yet none knows well ## 2235 To shun the heaven that leads men to this hell. ## 2236 ## 2237 CXXX ## 2238 ## 2239 My mistress' eyes are nothing like the sun; ## 2240 Coral is far more red, than her lips red: ## 2241 If snow be white, why then her breasts are dun; ## 2242 If hairs be wires, black wires grow on her head. ## 2243 I have seen roses damask'd, red and white, ## 2244 But no such roses see I in her cheeks; ## 2245 And in some perfumes is there more delight ## 2246 Than in the breath that from my mistress reeks. ## 2247 I love to hear her speak, yet well I know ## 2248 That music hath a far more pleasing sound: ## 2249 I grant I never saw a goddess go,-- ## 2250 My mistress, when she walks, treads on the ground: ## 2251 And yet by heaven, I think my love as rare, ## 2252 As any she belied with false compare. ## 2253 ## 2254 CXXXI ## 2255 ## 2256 Thou art as tyrannous, so as thou art, ## 2257 As those whose beauties proudly make them cruel; ## 2258 For well thou know'st to my dear doting heart ## 2259 Thou art the fairest and most precious jewel. ## 2260 Yet, in good faith, some say that thee behold, ## 2261 Thy face hath not the power to make love groan; ## 2262 To say they err I dare not be so bold, ## 2263 Although I swear it to myself alone. ## 2264 And to be sure that is not false I swear, ## 2265 A thousand groans, but thinking on thy face, ## 2266 One on another's neck, do witness bear ## 2267 Thy black is fairest in my judgment's place. ## 2268 In nothing art thou black save in thy deeds, ## 2269 And thence this slander, as I think, proceeds. ## 2270 ## 2271 CXXXII ## 2272 ## 2273 Thine eyes I love, and they, as pitying me, ## 2274 Knowing thy heart torment me with disdain, ## 2275 Have put on black and loving mourners be, ## 2276 Looking with pretty ruth upon my pain. ## 2277 And truly not the morning sun of heaven ## 2278 Better becomes the grey cheeks of the east, ## 2279 Nor that full star that ushers in the even, ## 2280 Doth half that glory to the sober west, ## 2281 As those two mourning eyes become thy face: ## 2282 O! let it then as well beseem thy heart ## 2283 To mourn for me since mourning doth thee grace, ## 2284 And suit thy pity like in every part. ## 2285 Then will I swear beauty herself is black, ## 2286 And all they foul that thy complexion lack. ## 2287 ## 2288 CXXXIII ## 2289 ## 2290 Beshrew that heart that makes my heart to groan ## 2291 For that deep wound it gives my friend and me! ## 2292 Is't not enough to torture me alone, ## 2293 But slave to slavery my sweet'st friend must be? ## 2294 Me from myself thy cruel eye hath taken, ## 2295 And my next self thou harder hast engross'd: ## 2296 Of him, myself, and thee I am forsaken; ## 2297 A torment thrice three-fold thus to be cross'd: ## 2298 Prison my heart in thy steel bosom's ward, ## 2299 But then my friend's heart let my poor heart bail; ## 2300 Whoe'er keeps me, let my heart be his guard; ## 2301 Thou canst not then use rigour in my jail: ## 2302 And yet thou wilt; for I, being pent in thee, ## 2303 Perforce am thine, and all that is in me. ## 2304 ## 2305 CXXXIV ## 2306 ## 2307 So, now I have confess'd that he is thine, ## 2308 And I my self am mortgag'd to thy will, ## 2309 Myself I'll forfeit, so that other mine ## 2310 Thou wilt restore to be my comfort still: ## 2311 But thou wilt not, nor he will not be free, ## 2312 For thou art covetous, and he is kind; ## 2313 He learn'd but surety-like to write for me, ## 2314 Under that bond that him as fast doth bind. ## 2315 The statute of thy beauty thou wilt take, ## 2316 Thou usurer, that putt'st forth all to use, ## 2317 And sue a friend came debtor for my sake; ## 2318 So him I lose through my unkind abuse. ## 2319 Him have I lost; thou hast both him and me: ## 2320 He pays the whole, and yet am I not free. ## 2321 ## 2322 CXXXV ## 2323 ## 2324 Whoever hath her wish, thou hast thy 'Will,' ## 2325 And 'Will' to boot, and 'Will' in over-plus; ## 2326 More than enough am I that vex'd thee still, ## 2327 To thy sweet will making addition thus. ## 2328 Wilt thou, whose will is large and spacious, ## 2329 Not once vouchsafe to hide my will in thine? ## 2330 Shall will in others seem right gracious, ## 2331 And in my will no fair acceptance shine? ## 2332 The sea, all water, yet receives rain still, ## 2333 And in abundance addeth to his store; ## 2334 So thou, being rich in 'Will,' add to thy 'Will' ## 2335 One will of mine, to make thy large will more. ## 2336 Let no unkind 'No' fair beseechers kill; ## 2337 Think all but one, and me in that one 'Will.' ## 2338 ## 2339 CXXXVI ## 2340 ## 2341 If thy soul check thee that I come so near, ## 2342 Swear to thy blind soul that I was thy 'Will', ## 2343 And will, thy soul knows, is admitted there; ## 2344 Thus far for love, my love-suit, sweet, fulfil. ## 2345 'Will', will fulfil the treasure of thy love, ## 2346 Ay, fill it full with wills, and my will one. ## 2347 In things of great receipt with ease we prove ## 2348 Among a number one is reckon'd none: ## 2349 Then in the number let me pass untold, ## 2350 Though in thy store's account I one must be; ## 2351 For nothing hold me, so it please thee hold ## 2352 That nothing me, a something sweet to thee: ## 2353 Make but my name thy love, and love that still, ## 2354 And then thou lov'st me for my name is 'Will.' ## 2355 ## 2356 CXXXVII ## 2357 ## 2358 Thou blind fool, Love, what dost thou to mine eyes, ## 2359 That they behold, and see not what they see? ## 2360 They know what beauty is, see where it lies, ## 2361 Yet what the best is take the worst to be. ## 2362 If eyes, corrupt by over-partial looks, ## 2363 Be anchor'd in the bay where all men ride, ## 2364 Why of eyes' falsehood hast thou forged hooks, ## 2365 Whereto the judgment of my heart is tied? ## 2366 Why should my heart think that a several plot, ## 2367 Which my heart knows the wide world's common place? ## 2368 Or mine eyes, seeing this, say this is not, ## 2369 To put fair truth upon so foul a face? ## 2370 In things right true my heart and eyes have err'd, ## 2371 And to this false plague are they now transferr'd. ## 2372 ## 2373 CXXXVIII ## 2374 ## 2375 When my love swears that she is made of truth, ## 2376 I do believe her though I know she lies, ## 2377 That she might think me some untutor'd youth, ## 2378 Unlearned in the world's false subtleties. ## 2379 Thus vainly thinking that she thinks me young, ## 2380 Although she knows my days are past the best, ## 2381 Simply I credit her false-speaking tongue: ## 2382 On both sides thus is simple truth suppressed: ## 2383 But wherefore says she not she is unjust? ## 2384 And wherefore say not I that I am old? ## 2385 O! love's best habit is in seeming trust, ## 2386 And age in love, loves not to have years told: ## 2387 Therefore I lie with her, and she with me, ## 2388 And in our faults by lies we flatter'd be. ## 2389 ## 2390 CXXXIX ## 2391 ## 2392 O! call not me to justify the wrong ## 2393 That thy unkindness lays upon my heart; ## 2394 Wound me not with thine eye, but with thy tongue: ## 2395 Use power with power, and slay me not by art, ## 2396 Tell me thou lov'st elsewhere; but in my sight, ## 2397 Dear heart, forbear to glance thine eye aside: ## 2398 What need'st thou wound with cunning, when thy might ## 2399 Is more than my o'erpress'd defence can bide? ## 2400 Let me excuse thee: ah! my love well knows ## 2401 Her pretty looks have been mine enemies; ## 2402 And therefore from my face she turns my foes, ## 2403 That they elsewhere might dart their injuries: ## 2404 Yet do not so; but since I am near slain, ## 2405 Kill me outright with looks, and rid my pain. ## 2406 ## 2407 ## 2408 CXL ## 2409 ## 2410 Be wise as thou art cruel; do not press ## 2411 My tongue-tied patience with too much disdain; ## 2412 Lest sorrow lend me words, and words express ## 2413 The manner of my pity-wanting pain. ## 2414 If I might teach thee wit, better it were, ## 2415 Though not to love, yet, love to tell me so;-- ## 2416 As testy sick men, when their deaths be near, ## 2417 No news but health from their physicians know;-- ## 2418 For, if I should despair, I should grow mad, ## 2419 And in my madness might speak ill of thee; ## 2420 Now this ill-wresting world is grown so bad, ## 2421 Mad slanderers by mad ears believed be. ## 2422 That I may not be so, nor thou belied, ## 2423 Bear thine eyes straight, though thy proud heart go wide. ## 2424 ## 2425 CXLI ## 2426 ## 2427 In faith I do not love thee with mine eyes, ## 2428 For they in thee a thousand errors note; ## 2429 But 'tis my heart that loves what they despise, ## 2430 Who, in despite of view, is pleased to dote. ## 2431 Nor are mine ears with thy tongue's tune delighted; ## 2432 Nor tender feeling, to base touches prone, ## 2433 Nor taste, nor smell, desire to be invited ## 2434 To any sensual feast with thee alone: ## 2435 But my five wits nor my five senses can ## 2436 Dissuade one foolish heart from serving thee, ## 2437 Who leaves unsway'd the likeness of a man, ## 2438 Thy proud heart's slave and vassal wretch to be: ## 2439 Only my plague thus far I count my gain, ## 2440 That she that makes me sin awards me pain. ## 2441 ## 2442 CXLII ## 2443 ## 2444 Love is my sin, and thy dear virtue hate, ## 2445 Hate of my sin, grounded on sinful loving: ## 2446 O! but with mine compare thou thine own state, ## 2447 And thou shalt find it merits not reproving; ## 2448 Or, if it do, not from those lips of thine, ## 2449 That have profan'd their scarlet ornaments ## 2450 And seal'd false bonds of love as oft as mine, ## 2451 Robb'd others' beds' revenues of their rents. ## 2452 Be it lawful I love thee, as thou lov'st those ## 2453 Whom thine eyes woo as mine importune thee: ## 2454 Root pity in thy heart, that, when it grows, ## 2455 Thy pity may deserve to pitied be. ## 2456 If thou dost seek to have what thou dost hide, ## 2457 By self-example mayst thou be denied! ## 2458 ## 2459 CXLIII ## 2460 ## 2461 Lo, as a careful housewife runs to catch ## 2462 One of her feather'd creatures broke away, ## 2463 Sets down her babe, and makes all swift dispatch ## 2464 In pursuit of the thing she would have stay; ## 2465 Whilst her neglected child holds her in chase, ## 2466 Cries to catch her whose busy care is bent ## 2467 To follow that which flies before her face, ## 2468 Not prizing her poor infant's discontent; ## 2469 So runn'st thou after that which flies from thee, ## 2470 Whilst I thy babe chase thee afar behind; ## 2471 But if thou catch thy hope, turn back to me, ## 2472 And play the mother's part, kiss me, be kind; ## 2473 So will I pray that thou mayst have thy 'Will,' ## 2474 If thou turn back and my loud crying still. ## 2475 ## 2476 CXLIV ## 2477 ## 2478 Two loves I have of comfort and despair, ## 2479 Which like two spirits do suggest me still: ## 2480 The better angel is a man right fair, ## 2481 The worser spirit a woman colour'd ill. ## 2482 To win me soon to hell, my female evil, ## 2483 Tempteth my better angel from my side, ## 2484 And would corrupt my saint to be a devil, ## 2485 Wooing his purity with her foul pride. ## 2486 And whether that my angel be turn'd fiend, ## 2487 Suspect I may, yet not directly tell; ## 2488 But being both from me, both to each friend, ## 2489 I guess one angel in another's hell: ## 2490 Yet this shall I ne'er know, but live in doubt, ## 2491 Till my bad angel fire my good one out. ## 2492 ## 2493 CXLV ## 2494 ## 2495 Those lips that Love's own hand did make, ## 2496 Breathed forth the sound that said 'I hate', ## 2497 To me that languish'd for her sake: ## 2498 But when she saw my woeful state, ## 2499 Straight in her heart did mercy come, ## 2500 Chiding that tongue that ever sweet ## 2501 Was us'd in giving gentle doom; ## 2502 And taught it thus anew to greet; ## 2503 'I hate' she alter'd with an end, ## 2504 That followed it as gentle day, ## 2505 Doth follow night, who like a fiend ## 2506 From heaven to hell is flown away. ## 2507 'I hate', from hate away she threw, ## 2508 And sav'd my life, saying 'not you'. ## 2509 ## 2510 CXLVI ## 2511 ## 2512 Poor soul, the centre of my sinful earth, ## 2513 My sinful earth these rebel powers array, ## 2514 Why dost thou pine within and suffer dearth, ## 2515 Painting thy outward walls so costly gay? ## 2516 Why so large cost, having so short a lease, ## 2517 Dost thou upon thy fading mansion spend? ## 2518 Shall worms, inheritors of this excess, ## 2519 Eat up thy charge? Is this thy body's end? ## 2520 Then soul, live thou upon thy servant's loss, ## 2521 And let that pine to aggravate thy store; ## 2522 Buy terms divine in selling hours of dross; ## 2523 Within be fed, without be rich no more: ## 2524 So shall thou feed on Death, that feeds on men, ## 2525 And Death once dead, there's no more dying then. ## 2526 ## 2527 CXLVII ## 2528 ## 2529 My love is as a fever longing still, ## 2530 For that which longer nurseth the disease; ## 2531 Feeding on that which doth preserve the ill, ## 2532 The uncertain sickly appetite to please. ## 2533 My reason, the physician to my love, ## 2534 Angry that his prescriptions are not kept, ## 2535 Hath left me, and I desperate now approve ## 2536 Desire is death, which physic did except. ## 2537 Past cure I am, now Reason is past care, ## 2538 And frantic-mad with evermore unrest; ## 2539 My thoughts and my discourse as madmen's are, ## 2540 At random from the truth vainly express'd; ## 2541 For I have sworn thee fair, and thought thee bright, ## 2542 Who art as black as hell, as dark as night. ## 2543 ## 2544 CXLVIII ## 2545 ## 2546 O me! what eyes hath Love put in my head, ## 2547 Which have no correspondence with true sight; ## 2548 Or, if they have, where is my judgment fled, ## 2549 That censures falsely what they see aright? ## 2550 If that be fair whereon my false eyes dote, ## 2551 What means the world to say it is not so? ## 2552 If it be not, then love doth well denote ## 2553 Love's eye is not so true as all men's: no, ## 2554 How can it? O! how can Love's eye be true, ## 2555 That is so vexed with watching and with tears? ## 2556 No marvel then, though I mistake my view; ## 2557 The sun itself sees not, till heaven clears. ## 2558 O cunning Love! with tears thou keep'st me blind, ## 2559 Lest eyes well-seeing thy foul faults should find. ## 2560 ## 2561 CXLIX ## 2562 ## 2563 Canst thou, O cruel! say I love thee not, ## 2564 When I against myself with thee partake? ## 2565 Do I not think on thee, when I forgot ## 2566 Am of my self, all tyrant, for thy sake? ## 2567 Who hateth thee that I do call my friend, ## 2568 On whom frown'st thou that I do fawn upon, ## 2569 Nay, if thou lour'st on me, do I not spend ## 2570 Revenge upon myself with present moan? ## 2571 What merit do I in my self respect, ## 2572 That is so proud thy service to despise, ## 2573 When all my best doth worship thy defect, ## 2574 Commanded by the motion of thine eyes? ## 2575 But, love, hate on, for now I know thy mind; ## 2576 Those that can see thou lov'st, and I am blind. ## 2577 ## 2578 CL ## 2579 ## 2580 O! from what power hast thou this powerful might, ## 2581 With insufficiency my heart to sway? ## 2582 To make me give the lie to my true sight, ## 2583 And swear that brightness doth not grace the day? ## 2584 Whence hast thou this becoming of things ill, ## 2585 That in the very refuse of thy deeds ## 2586 There is such strength and warrantise of skill, ## 2587 That, in my mind, thy worst all best exceeds? ## 2588 Who taught thee how to make me love thee more, ## 2589 The more I hear and see just cause of hate? ## 2590 O! though I love what others do abhor, ## 2591 With others thou shouldst not abhor my state: ## 2592 If thy unworthiness rais'd love in me, ## 2593 More worthy I to be belov'd of thee. ## 2594 ## 2595 CLI ## 2596 ## 2597 Love is too young to know what conscience is, ## 2598 Yet who knows not conscience is born of love? ## 2599 Then, gentle cheater, urge not my amiss, ## 2600 Lest guilty of my faults thy sweet self prove: ## 2601 For, thou betraying me, I do betray ## 2602 My nobler part to my gross body's treason; ## 2603 My soul doth tell my body that he may ## 2604 Triumph in love; flesh stays no farther reason, ## 2605 But rising at thy name doth point out thee, ## 2606 As his triumphant prize. Proud of this pride, ## 2607 He is contented thy poor drudge to be, ## 2608 To stand in thy affairs, fall by thy side. ## 2609 No want of conscience hold it that I call ## 2610 Her 'love,' for whose dear love I rise and fall. ## 2611 ## 2612 CLII ## 2613 ## 2614 In loving thee thou know'st I am forsworn, ## 2615 But thou art twice forsworn, to me love swearing; ## 2616 In act thy bed-vow broke, and new faith torn, ## 2617 In vowing new hate after new love bearing: ## 2618 But why of two oaths' breach do I accuse thee, ## 2619 When I break twenty? I am perjur'd most; ## 2620 For all my vows are oaths but to misuse thee, ## 2621 And all my honest faith in thee is lost: ## 2622 For I have sworn deep oaths of thy deep kindness, ## 2623 Oaths of thy love, thy truth, thy constancy; ## 2624 And, to enlighten thee, gave eyes to blindness, ## 2625 Or made them swear against the thing they see; ## 2626 For I have sworn thee fair; more perjur'd I, ## 2627 To swear against the truth so foul a lie! ## 2628 ## 2629 CLIII ## 2630 ## 2631 Cupid laid by his brand and fell asleep: ## 2632 A maid of Dian's this advantage found, ## 2633 And his love-kindling fire did quickly steep ## 2634 In a cold valley-fountain of that ground; ## 2635 Which borrow'd from this holy fire of Love, ## 2636 A dateless lively heat, still to endure, ## 2637 And grew a seeting bath, which yet men prove ## 2638 Against strange maladies a sovereign cure. ## 2639 But at my mistress' eye Love's brand new-fired, ## 2640 The boy for trial needs would touch my breast; ## 2641 I, sick withal, the help of bath desired, ## 2642 And thither hied, a sad distemper'd guest, ## 2643 But found no cure, the bath for my help lies ## 2644 Where Cupid got new fire; my mistress' eyes. ## 2645 ## 2646 CLIV ## 2647 ## 2648 The little Love-god lying once asleep, ## 2649 Laid by his side his heart-inflaming brand, ## 2650 Whilst many nymphs that vow'd chaste life to keep ## 2651 Came tripping by; but in her maiden hand ## 2652 The fairest votary took up that fire ## 2653 Which many legions of true hearts had warm'd; ## 2654 And so the general of hot desire ## 2655 Was, sleeping, by a virgin hand disarm'd. ## 2656 This brand she quenched in a cool well by, ## 2657 Which from Love's fire took heat perpetual, ## 2658 Growing a bath and healthful remedy, ## 2659 For men diseas'd; but I, my mistress' thrall, ## 2660 Came there for cure and this by that I prove, ## 2661 Love's fire heats water, water cools not love. ## 2662 ## 2663 ## 2664 ## 2665 ## 2666 ## 2667 ## 2668 ## 2669 ## 2670 ## 2671 ## 2672 End of Project Gutenberg's Shakespeare's Sonnets, by William Shakespeare ## 2673 ## 2674 *** END OF THIS PROJECT GUTENBERG EBOOK SHAKESPEARE'S SONNETS *** ## 2675 ## 2676 ***** This file should be named 1041.txt or 1041.zip ***** ## 2677 This and all associated files of various formats will be found in: ## 2678 http://www.gutenberg.org/1/0/4/1041/ ## 2679 ## 2680 Produced by Joseph S. Miller and Embry-Riddle Aeronautical ## 2681 University Library. HTML version by Al Haines. ## 2682 ## 2683 ## 2684 Updated editions will replace the previous one--the old editions ## 2685 will be renamed. ## 2686 ## 2687 Creating the works from public domain print editions means that no ## 2688 one owns a United States copyright in these works, so the Foundation ## 2689 (and you!) can copy and distribute it in the United States without ## 2690 permission and without paying copyright royalties. Special rules, ## 2691 set forth in the General Terms of Use part of this license, apply to ## 2692 copying and distributing Project Gutenberg-tm electronic works to ## 2693 protect the PROJECT GUTENBERG-tm concept and trademark. Project ## 2694 Gutenberg is a registered trademark, and may not be used if you ## 2695 charge for the eBooks, unless you receive specific permission. If you ## 2696 do not charge anything for copies of this eBook, complying with the ## 2697 rules is very easy. You may use this eBook for nearly any purpose ## 2698 such as creation of derivative works, reports, performances and ## 2699 research. They may be modified and printed and given away--you may do ## 2700 practically ANYTHING with public domain eBooks. Redistribution is ## 2701 subject to the trademark license, especially commercial ## 2702 redistribution. ## 2703 ## 2704 ## 2705 ## 2706 *** START: FULL LICENSE *** ## 2707 ## 2708 THE FULL PROJECT GUTENBERG LICENSE ## 2709 PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK ## 2710 ## 2711 To protect the Project Gutenberg-tm mission of promoting the free ## 2712 distribution of electronic works, by using or distributing this work ## 2713 (or any other work associated in any way with the phrase "Project ## 2714 Gutenberg"), you agree to comply with all the terms of the Full Project ## 2715 Gutenberg-tm License available with this file or online at ## 2716 www.gutenberg.org/license. ## 2717 ## 2718 ## 2719 Section 1. General Terms of Use and Redistributing Project Gutenberg-tm ## 2720 electronic works ## 2721 ## 2722 1.A. By reading or using any part of this Project Gutenberg-tm ## 2723 electronic work, you indicate that you have read, understand, agree to ## 2724 and accept all the terms of this license and intellectual property ## 2725 (trademark/copyright) agreement. If you do not agree to abide by all ## 2726 the terms of this agreement, you must cease using and return or destroy ## 2727 all copies of Project Gutenberg-tm electronic works in your possession. ## 2728 If you paid a fee for obtaining a copy of or access to a Project ## 2729 Gutenberg-tm electronic work and you do not agree to be bound by the ## 2730 terms of this agreement, you may obtain a refund from the person or ## 2731 entity to whom you paid the fee as set forth in paragraph 1.E.8. ## 2732 ## 2733 1.B. "Project Gutenberg" is a registered trademark. It may only be ## 2734 used on or associated in any way with an electronic work by people who ## 2735 agree to be bound by the terms of this agreement. There are a few ## 2736 things that you can do with most Project Gutenberg-tm electronic works ## 2737 even without complying with the full terms of this agreement. See ## 2738 paragraph 1.C below. There are a lot of things you can do with Project ## 2739 Gutenberg-tm electronic works if you follow the terms of this agreement ## 2740 and help preserve free future access to Project Gutenberg-tm electronic ## 2741 works. See paragraph 1.E below. ## 2742 ## 2743 1.C. The Project Gutenberg Literary Archive Foundation ("the Foundation" ## 2744 or PGLAF), owns a compilation copyright in the collection of Project ## 2745 Gutenberg-tm electronic works. Nearly all the individual works in the ## 2746 collection are in the public domain in the United States. If an ## 2747 individual work is in the public domain in the United States and you are ## 2748 located in the United States, we do not claim a right to prevent you from ## 2749 copying, distributing, performing, displaying or creating derivative ## 2750 works based on the work as long as all references to Project Gutenberg ## 2751 are removed. Of course, we hope that you will support the Project ## 2752 Gutenberg-tm mission of promoting free access to electronic works by ## 2753 freely sharing Project Gutenberg-tm works in compliance with the terms of ## 2754 this agreement for keeping the Project Gutenberg-tm name associated with ## 2755 the work. You can easily comply with the terms of this agreement by ## 2756 keeping this work in the same format with its attached full Project ## 2757 Gutenberg-tm License when you share it without charge with others. ## 2758 ## 2759 1.D. The copyright laws of the place where you are located also govern ## 2760 what you can do with this work. Copyright laws in most countries are in ## 2761 a constant state of change. If you are outside the United States, check ## 2762 the laws of your country in addition to the terms of this agreement ## 2763 before downloading, copying, displaying, performing, distributing or ## 2764 creating derivative works based on this work or any other Project ## 2765 Gutenberg-tm work. The Foundation makes no representations concerning ## 2766 the copyright status of any work in any country outside the United ## 2767 States. ## 2768 ## 2769 1.E. Unless you have removed all references to Project Gutenberg: ## 2770 ## 2771 1.E.1. The following sentence, with active links to, or other immediate ## 2772 access to, the full Project Gutenberg-tm License must appear prominently ## 2773 whenever any copy of a Project Gutenberg-tm work (any work on which the ## 2774 phrase "Project Gutenberg" appears, or with which the phrase "Project ## 2775 Gutenberg" is associated) is accessed, displayed, performed, viewed, ## 2776 copied or distributed: ## 2777 ## 2778 This eBook is for the use of anyone anywhere at no cost and with ## 2779 almost no restrictions whatsoever. You may copy it, give it away or ## 2780 re-use it under the terms of the Project Gutenberg License included ## 2781 with this eBook or online at www.gutenberg.org ## 2782 ## 2783 1.E.2. If an individual Project Gutenberg-tm electronic work is derived ## 2784 from the public domain (does not contain a notice indicating that it is ## 2785 posted with permission of the copyright holder), the work can be copied ## 2786 and distributed to anyone in the United States without paying any fees ## 2787 or charges. If you are redistributing or providing access to a work ## 2788 with the phrase "Project Gutenberg" associated with or appearing on the ## 2789 work, you must comply either with the requirements of paragraphs 1.E.1 ## 2790 through 1.E.7 or obtain permission for the use of the work and the ## 2791 Project Gutenberg-tm trademark as set forth in paragraphs 1.E.8 or ## 2792 1.E.9. ## 2793 ## 2794 1.E.3. If an individual Project Gutenberg-tm electronic work is posted ## 2795 with the permission of the copyright holder, your use and distribution ## 2796 must comply with both paragraphs 1.E.1 through 1.E.7 and any additional ## 2797 terms imposed by the copyright holder. Additional terms will be linked ## 2798 to the Project Gutenberg-tm License for all works posted with the ## 2799 permission of the copyright holder found at the beginning of this work. ## 2800 ## 2801 1.E.4. Do not unlink or detach or remove the full Project Gutenberg-tm ## 2802 License terms from this work, or any files containing a part of this ## 2803 work or any other work associated with Project Gutenberg-tm. ## 2804 ## 2805 1.E.5. Do not copy, display, perform, distribute or redistribute this ## 2806 electronic work, or any part of this electronic work, without ## 2807 prominently displaying the sentence set forth in paragraph 1.E.1 with ## 2808 active links or immediate access to the full terms of the Project ## 2809 Gutenberg-tm License. ## 2810 ## 2811 1.E.6. You may convert to and distribute this work in any binary, ## 2812 compressed, marked up, nonproprietary or proprietary form, including any ## 2813 word processing or hypertext form. However, if you provide access to or ## 2814 distribute copies of a Project Gutenberg-tm work in a format other than ## 2815 "Plain Vanilla ASCII" or other format used in the official version ## 2816 posted on the official Project Gutenberg-tm web site (www.gutenberg.org), ## 2817 you must, at no additional cost, fee or expense to the user, provide a ## 2818 copy, a means of exporting a copy, or a means of obtaining a copy upon ## 2819 request, of the work in its original "Plain Vanilla ASCII" or other ## 2820 form. Any alternate format must include the full Project Gutenberg-tm ## 2821 License as specified in paragraph 1.E.1. ## 2822 ## 2823 1.E.7. Do not charge a fee for access to, viewing, displaying, ## 2824 performing, copying or distributing any Project Gutenberg-tm works ## 2825 unless you comply with paragraph 1.E.8 or 1.E.9. ## 2826 ## 2827 1.E.8. You may charge a reasonable fee for copies of or providing ## 2828 access to or distributing Project Gutenberg-tm electronic works provided ## 2829 that ## 2830 ## 2831 - You pay a royalty fee of 20% of the gross profits you derive from ## 2832 the use of Project Gutenberg-tm works calculated using the method ## 2833 you already use to calculate your applicable taxes. The fee is ## 2834 owed to the owner of the Project Gutenberg-tm trademark, but he ## 2835 has agreed to donate royalties under this paragraph to the ## 2836 Project Gutenberg Literary Archive Foundation. Royalty payments ## 2837 must be paid within 60 days following each date on which you ## 2838 prepare (or are legally required to prepare) your periodic tax ## 2839 returns. Royalty payments should be clearly marked as such and ## 2840 sent to the Project Gutenberg Literary Archive Foundation at the ## 2841 address specified in Section 4, "Information about donations to ## 2842 the Project Gutenberg Literary Archive Foundation." ## 2843 ## 2844 - You provide a full refund of any money paid by a user who notifies ## 2845 you in writing (or by e-mail) within 30 days of receipt that s/he ## 2846 does not agree to the terms of the full Project Gutenberg-tm ## 2847 License. You must require such a user to return or ## 2848 destroy all copies of the works possessed in a physical medium ## 2849 and discontinue all use of and all access to other copies of ## 2850 Project Gutenberg-tm works. ## 2851 ## 2852 - You provide, in accordance with paragraph 1.F.3, a full refund of any ## 2853 money paid for a work or a replacement copy, if a defect in the ## 2854 electronic work is discovered and reported to you within 90 days ## 2855 of receipt of the work. ## 2856 ## 2857 - You comply with all other terms of this agreement for free ## 2858 distribution of Project Gutenberg-tm works. ## 2859 ## 2860 1.E.9. If you wish to charge a fee or distribute a Project Gutenberg-tm ## 2861 electronic work or group of works on different terms than are set ## 2862 forth in this agreement, you must obtain permission in writing from ## 2863 both the Project Gutenberg Literary Archive Foundation and Michael ## 2864 Hart, the owner of the Project Gutenberg-tm trademark. Contact the ## 2865 Foundation as set forth in Section 3 below. ## 2866 ## 2867 1.F. ## 2868 ## 2869 1.F.1. Project Gutenberg volunteers and employees expend considerable ## 2870 effort to identify, do copyright research on, transcribe and proofread ## 2871 public domain works in creating the Project Gutenberg-tm ## 2872 collection. Despite these efforts, Project Gutenberg-tm electronic ## 2873 works, and the medium on which they may be stored, may contain ## 2874 "Defects," such as, but not limited to, incomplete, inaccurate or ## 2875 corrupt data, transcription errors, a copyright or other intellectual ## 2876 property infringement, a defective or damaged disk or other medium, a ## 2877 computer virus, or computer codes that damage or cannot be read by ## 2878 your equipment. ## 2879 ## 2880 1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for the "Right ## 2881 of Replacement or Refund" described in paragraph 1.F.3, the Project ## 2882 Gutenberg Literary Archive Foundation, the owner of the Project ## 2883 Gutenberg-tm trademark, and any other party distributing a Project ## 2884 Gutenberg-tm electronic work under this agreement, disclaim all ## 2885 liability to you for damages, costs and expenses, including legal ## 2886 fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE, STRICT ## 2887 LIABILITY, BREACH OF WARRANTY OR BREACH OF CONTRACT EXCEPT THOSE ## 2888 PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE THAT THE FOUNDATION, THE ## 2889 TRADEMARK OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE ## 2890 LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE OR ## 2891 INCIDENTAL DAMAGES EVEN IF YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH ## 2892 DAMAGE. ## 2893 ## 2894 1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you discover a ## 2895 defect in this electronic work within 90 days of receiving it, you can ## 2896 receive a refund of the money (if any) you paid for it by sending a ## 2897 written explanation to the person you received the work from. If you ## 2898 received the work on a physical medium, you must return the medium with ## 2899 your written explanation. The person or entity that provided you with ## 2900 the defective work may elect to provide a replacement copy in lieu of a ## 2901 refund. If you received the work electronically, the person or entity ## 2902 providing it to you may choose to give you a second opportunity to ## 2903 receive the work electronically in lieu of a refund. If the second copy ## 2904 is also defective, you may demand a refund in writing without further ## 2905 opportunities to fix the problem. ## 2906 ## 2907 1.F.4. Except for the limited right of replacement or refund set forth ## 2908 in paragraph 1.F.3, this work is provided to you 'AS-IS', WITH NO OTHER ## 2909 WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ## 2910 WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PURPOSE. ## 2911 ## 2912 1.F.5. Some states do not allow disclaimers of certain implied ## 2913 warranties or the exclusion or limitation of certain types of damages. ## 2914 If any disclaimer or limitation set forth in this agreement violates the ## 2915 law of the state applicable to this agreement, the agreement shall be ## 2916 interpreted to make the maximum disclaimer or limitation permitted by ## 2917 the applicable state law. The invalidity or unenforceability of any ## 2918 provision of this agreement shall not void the remaining provisions. ## 2919 ## 2920 1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation, the ## 2921 trademark owner, any agent or employee of the Foundation, anyone ## 2922 providing copies of Project Gutenberg-tm electronic works in accordance ## 2923 with this agreement, and any volunteers associated with the production, ## 2924 promotion and distribution of Project Gutenberg-tm electronic works, ## 2925 harmless from all liability, costs and expenses, including legal fees, ## 2926 that arise directly or indirectly from any of the following which you do ## 2927 or cause to occur: (a) distribution of this or any Project Gutenberg-tm ## 2928 work, (b) alteration, modification, or additions or deletions to any ## 2929 Project Gutenberg-tm work, and (c) any Defect you cause. ## 2930 ## 2931 ## 2932 Section 2. Information about the Mission of Project Gutenberg-tm ## 2933 ## 2934 Project Gutenberg-tm is synonymous with the free distribution of ## 2935 electronic works in formats readable by the widest variety of computers ## 2936 including obsolete, old, middle-aged and new computers. It exists ## 2937 because of the efforts of hundreds of volunteers and donations from ## 2938 people in all walks of life. ## 2939 ## 2940 Volunteers and financial support to provide volunteers with the ## 2941 assistance they need are critical to reaching Project Gutenberg-tm's ## 2942 goals and ensuring that the Project Gutenberg-tm collection will ## 2943 remain freely available for generations to come. In 2001, the Project ## 2944 Gutenberg Literary Archive Foundation was created to provide a secure ## 2945 and permanent future for Project Gutenberg-tm and future generations. ## 2946 To learn more about the Project Gutenberg Literary Archive Foundation ## 2947 and how your efforts and donations can help, see Sections 3 and 4 ## 2948 and the Foundation information page at www.gutenberg.org ## 2949 ## 2950 ## 2951 Section 3. Information about the Project Gutenberg Literary Archive ## 2952 Foundation ## 2953 ## 2954 The Project Gutenberg Literary Archive Foundation is a non profit ## 2955 501(c)(3) educational corporation organized under the laws of the ## 2956 state of Mississippi and granted tax exempt status by the Internal ## 2957 Revenue Service. The Foundation's EIN or federal tax identification ## 2958 number is 64-6221541. Contributions to the Project Gutenberg ## 2959 Literary Archive Foundation are tax deductible to the full extent ## 2960 permitted by U.S. federal laws and your state's laws. ## 2961 ## 2962 The Foundation's principal office is located at 4557 Melan Dr. S. ## 2963 Fairbanks, AK, 99712., but its volunteers and employees are scattered ## 2964 throughout numerous locations. Its business office is located at 809 ## 2965 North 1500 West, Salt Lake City, UT 84116, (801) 596-1887. Email ## 2966 contact links and up to date contact information can be found at the ## 2967 Foundation's web site and official page at www.gutenberg.org/contact ## 2968 ## 2969 For additional contact information: ## 2970 Dr. Gregory B. Newby ## 2971 Chief Executive and Director ## 2972 gbnewby@pglaf.org ## 2973 ## 2974 Section 4. Information about Donations to the Project Gutenberg ## 2975 Literary Archive Foundation ## 2976 ## 2977 Project Gutenberg-tm depends upon and cannot survive without wide ## 2978 spread public support and donations to carry out its mission of ## 2979 increasing the number of public domain and licensed works that can be ## 2980 freely distributed in machine readable form accessible by the widest ## 2981 array of equipment including outdated equipment. Many small donations ## 2982 ($1 to $5,000) are particularly important to maintaining tax exempt ## 2983 status with the IRS. ## 2984 ## 2985 The Foundation is committed to complying with the laws regulating ## 2986 charities and charitable donations in all 50 states of the United ## 2987 States. Compliance requirements are not uniform and it takes a ## 2988 considerable effort, much paperwork and many fees to meet and keep up ## 2989 with these requirements. We do not solicit donations in locations ## 2990 where we have not received written confirmation of compliance. To ## 2991 SEND DONATIONS or determine the status of compliance for any ## 2992 particular state visit www.gutenberg.org/donate ## 2993 ## 2994 While we cannot and do not solicit contributions from states where we ## 2995 have not met the solicitation requirements, we know of no prohibition ## 2996 against accepting unsolicited donations from donors in such states who ## 2997 approach us with offers to donate. ## 2998 ## 2999 International donations are gratefully accepted, but we cannot make ## 3000 any statements concerning tax treatment of donations received from ## 3001 outside the United States. U.S. laws alone swamp our small staff. ## 3002 ## 3003 Please check the Project Gutenberg Web pages for current donation ## 3004 methods and addresses. Donations are accepted in a number of other ## 3005 ways including checks, online payments and credit card donations. ## 3006 To donate, please visit: www.gutenberg.org/donate ## 3007 ## 3008 ## 3009 Section 5. General Information About Project Gutenberg-tm electronic ## 3010 works. ## 3011 ## 3012 Professor Michael S. Hart was the originator of the Project Gutenberg-tm ## 3013 concept of a library of electronic works that could be freely shared ## 3014 with anyone. For forty years, he produced and distributed Project ## 3015 Gutenberg-tm eBooks with only a loose network of volunteer support. ## 3016 ## 3017 Project Gutenberg-tm eBooks are often created from several printed ## 3018 editions, all of which are confirmed as Public Domain in the U.S. ## 3019 unless a copyright notice is included. Thus, we do not necessarily ## 3020 keep eBooks in compliance with any particular paper edition. ## 3021 ## 3022 Most people start at our Web site which has the main PG search facility: ## 3023 ## 3024 www.gutenberg.org ## 3025 ## 3026 This Web site includes information about Project Gutenberg-tm, ## 3027 including how to make donations to the Project Gutenberg Literary ## 3028 Archive Foundation, how to help produce our new eBooks, and how to ## 3029 subscribe to our email newsletter to hear about new eBooks. ``` --- # Reading text (cont.) ### Scroll: more and less The `more` and `less` commands provide extra functionality over `cat`. For example, they allow you to move through long text one page at a time. - Try this yourself with `$ more examples/sonnets.txt` - You can move forward and back using the "f" and "b" keys, and quit by hitting "q". ### Preview: head and tail The `head` and `tail` commands let you limit yourself to a preview of the text, down to a specified number of rows. (The default is 10 rows if you don't specify a number.) ```bash $ head -n 3 examples/sonnets.txt ## First 3 rows $ # head examples/sonnets.txt ## First 10 rows (default) ``` ``` ## The Project Gutenberg EBook of Shakespeare's Sonnets, by William Shakespeare ## ## This eBook is for the use of anyone anywhere at no cost and with ``` --- # Reading text (cont.) ### Preview: head and tail (cont.) `tail` works very similarly to `head`, but starting from the bottom. For example, we can see the very last row of a file as follows ```bash $ tail -n 1 examples/sonnets.txt ## Last row ``` ``` ## subscribe to our email newsletter to hear about new eBooks. ``` -- However, there's one other neat option that I want to show you. By using the `-n +N` option, we can specify that we want to preview all lines starting from row N *and after*. E.g. ```bash $ tail -n +3024 examples/sonnets.txt ## Show everything from line 3024 ``` ``` ## www.gutenberg.org ## ## This Web site includes information about Project Gutenberg-tm, ## including how to make donations to the Project Gutenberg Literary ## Archive Foundation, how to help produce our new eBooks, and how to ## subscribe to our email newsletter to hear about new eBooks. ``` --- # Find patterns: grep To find patterns in text, we can use regular expression-type matching with `grep`. For example, say we want to find the famous opening line to Shakespeare's [Sonnet 18](https://en.wikipedia.org/wiki/Sonnet_18). - I'm going to include the `-n` ("number") flag to get the line that it occurs on. ```bash $ grep -n "Shall I compare thee" examples/sonnets.txt ``` ``` ## 336: Shall I compare thee to a summer's day? ``` -- By default, `grep` returns all matching patterns. - What happens if you run `$ grep -n "summer" examples/sonnets.txt`? - Or, for that matter, `$ grep -n "the" examples/sonnets.txt`? --- # Find patterns: grep (cont.) Note that `grep` can be used to identify patterns in a group files (e.g. within a directory) too. - This is particularly useful if you are trying to identify a file that contain, say, a function name. Here's a simple example: Which days will I eat pasta this week? - I'm using the `R` (recursive) and `l` (just list the files; don't print the output) flags. ```bash $ grep -Rl "pasta" examples/meals ``` ``` ## examples/meals/monday.csv ``` -- What about muesli? And pizza? -- Take a look at the `grep` man or cheat file for other useful examples and flags (e.g. `-i` for ignore case). PS — Another cool (and very fast) shell utility along these lines is [the silver searcher](https://github.com/ggreer/the_silver_searcher). Check it out. --- # Manipulate text: sed and awk There are two main commands for manipulating text in the shell, namely `sed` and `awk`. - Both of these are very powerful and flexible (`awk` is particularly good with CSVs). I'm going to show two basic examples without going into depth, but I strongly encourage you to explore more on your own. (Mac users: See [here](https://unix.stackexchange.com/questions/13711/differences-between-sed-on-mac-osx-and-other-standard-sed).) -- **Example 1.** Replace one text pattern with another. ```bash $ cat examples/nursery.txt ``` ``` ## Jack and Jill ## Went up the hill ``` Now, change "Jack" to "Bill". ```bash $ sed -i 's/Jack/Bill/g' examples/nursery.txt $ cat examples/nursery.txt ``` ``` ## Bill and Jill ## Went up the hill ``` --- # Manipulate text: sed and awk (cont.) **Example 2.** Find and count the 10 most commonly used words in Shakespeare's Sonnets. - Note: We'll learn more about the pipe operator (`|`) in a few slides. ```bash $ sed -e 's/\s/\n/g' < examples/sonnets.txt | sort | uniq -c | sort -nr | head -10 ``` ``` ## 8884 ## 513 the ## 456 of ## 401 to ## 341 my ## 338 in ## 327 I ## 316 and ## 252 thy ## 248 that ``` -- </br> PS — You can also use double quotes (") instead of single ones (') for `sed` and `awk` commands. This can sometimes run you into trouble with special symbols or patterns in the text, though. (Mostly, I want you to be mindful of accidental matching or closing quotation mark pairs.) --- # Sorting and removing duplicates: sort We can remove duplicate lines in various ways in Bash, but I'll demonstrate using `sort`. ```bash $ cat examples/reps.txt ``` ``` ## Sometimes I repeat myself. ## Sometimes I repeat myself. ## Other times not so much. ## But I try to be good. ## Other times not so much. ## Sometimes I repeat myself. ``` There's a fair bit of repetition in this file (and a double entendre). Let's fix that. - Note the use of the `-u` ("unique") flag to remove duplicates. I'll also add a `-r` ("reverse") flag, but only because `sort` orders alphabetically and this makes less sense for this simple example. ```bash $ sort -ur examples/reps.txt ``` ``` ## Sometimes I repeat myself. ## Other times not so much. ## But I try to be good. ``` --- class: inverse, center, middle name: pipes # Redirecting and pipes <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> --- # Redirect: > You can send output from the shell to a file using the redirect operator `>` For example, let's print a message to the shell using the `echo` command. ```bash $ echo "At first, I was afraid, I was petrified" ``` ``` ## At first, I was afraid, I was petrified ``` -- If you wanted to save this output to a file, you need simply redirect it to the filename of choice. ```bash $ echo "At first, I was afraid, I was petrified" > survive.txt $ find survive.txt ## Show that it now exists ``` ``` ## survive.txt ``` --- # Redirect: > (cont.) If you want to *append* text to an existing file, then you should use `>>`. - Using `>` will try to overwrite the existing file contents. ```bash $ echo "'Kept thinking I could never live without you by my side" >> survive.txt $ cat survive.txt ``` ``` ## At first, I was afraid, I was petrified ## 'Kept thinking I could never live without you by my side ``` -- </br> (Don't be shy. You can hum the rest of the song to yourself now.) -- </br> Aside: I often use this sequence when adding files to my .gitignore. E.g. `$ echo "*.csv" >> .gitignore`. --- # Pipes: | The pipe operator `|` is one of the coolest features in Bash. - It lets you send (i.e. "pipe") intermediate output to another command. - In other words, it allows us to chain together a sequence of simple operations and thereby implement a more complex operation. (Remember the Unix philosophy!) Let me demonstrate using a very simple example. ```bash $ cat -n examples/sonnets.txt | head -n100 | tail -n10 ``` ``` ## 91 Despite of wrinkles this thy golden time. ## 92 But if thou live, remember'd not to be, ## 93 Die single and thine image dies with thee. ## 94 ## 95 IV ## 96 ## 97 Unthrifty loveliness, why dost thou spend ## 98 Upon thy self thy beauty's legacy? ## 99 Nature's bequest gives nothing, but doth lend, ## 100 And being frank she lends to those are free: ``` --- # Pipes: | (cont.) An exercise: Say I want to pull out all of text from (but limited to) Sonnet 18. - How might you go about this task using the pipe and other Bash commands? - Tip: Use your knowledge of the starting line (i.e. 336) and the fact that sonnets are 14 lines long. -- ```bash $ tail -n +336 examples/sonnets.txt | head -n14 ``` ``` ## Shall I compare thee to a summer's day? ## Thou art more lovely and more temperate: ## Rough winds do shake the darling buds of May, ## And summer's lease hath all too short a date: ## Sometime too hot the eye of heaven shines, ## And often is his gold complexion dimm'd, ## And every fair from fair sometime declines, ## By chance, or nature's changing course untrimm'd: ## But thy eternal summer shall not fade, ## Nor lose possession of that fair thou ow'st, ## Nor shall death brag thou wander'st in his shade, ## When in eternal lines to time thou grow'st, ## So long as men can breathe, or eyes can see, ## So long lives this, and this gives life to thee. ``` --- # Pipes: | (cont.) A final aside about pipe the friends: You can use it to search through your Bash command history. - Every shell command you type is stored in a `~/.bash_history` file.<sup>1</sup> What happens if you type `$ cat ~/.bash_history | grep head`? .footnote[ <sup>1</sup> The file might change depending on your preferred shell. E.g. For Zsh it's `~/.zhistory`. ] -- </br> FWIW, I use this approach often to remind myself of certain shell commands that I tend to forget. A related and extremely useful command is [`Ctrl`+`R`](https://unix.stackexchange.com/questions/73498/how-to-cycle-through-reverse-i-search-in-bash), which lets you search and cycle through your shell history. --- class: inverse, center, middle name: iteration # Iteration (_for_ loops) <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> --- # _for_ loop syntax _for_ loops in Bash work similarly to other programming languages that you are probably familiar with. The basic syntax is ```bash for i in LIST do OPERATION $i ## the $ sign indicates a variable in bash done ``` -- We can also condense things into a single line by using ";" appropriately. ```bash for i in LIST; do OPERATION $i; done ``` -- I find the top approach more readable, but I may use single line approach in these slides to save vertical space. - Note: Using ";" isn't limited to _for loops_. Semicolons are a standard way to denote line endings in Bash. --- # Example 1: Print a sequence of numbers To help make things concrete, here's a simple _for_ loop in action. ```bash $ for i in 1 2 3 4 5; do echo $i; done ``` ``` ## 1 ## 2 ## 3 ## 4 ## 5 ``` -- FWIW, we can use bash's brace expansion (`{1..n}`) to save us from having to write out a long sequence of numbers. ```bash $ for i in {1..5}; do echo $i; done ``` ``` ## 1 ## 2 ## 3 ## 4 ## 5 ``` --- name: combine_csvs # Example 2: Combine CSVs Here's a more realistic _for_ loop use-case that I use quite often: Combining (i.e. concatenating) multiple CSVs. -- Say we want to combine all the "daily" files in the `examples/meals` directory into a single CSV, which I'll call `mealplan.csv`. Here's one attempt that incorporates various bash commands and tricks that we've learned so far. The basic idea is: 1. Create a new (empty) CSV 2. Then, loop over the relevant input files, appending their contents to our new CSV ```bash ## create an empty CSV $ touch examples/meals/mealplan.csv ## loop over the input files and append their contents to our new CSV $ for i in $(ls examples/meals/*day.csv) > do > cat $i >> examples/meals/mealplan.csv > done ``` -- Did it work? (See next slide.) --- # Example 2: Combine CSVs (cont.) ```bash $ cat examples/meals/mealplan.csv ``` ``` ## day,breakfast,lunch,dinner ## friday,pancakes,ramen,stew ## day,breakfast,lunch,dinner ## monday,muesli,sandwich,pasta ## day,breakfast,lunch,dinner ## saturday,muesli,sandwich,pad thai ## day,breakfast,lunch,dinner ## sunday,muesli,roast,leftovers ## day,breakfast,lunch,dinner ## thursday,muesli,salad,tacos ## day,breakfast,lunch,dinner ## tuesday,muesli,soup,roast ## day,breakfast,lunch,dinner ## wednesday,muesli,sandwich,pizza ``` -- Hmmm. Sort of, but we need to get rid of the repeating header. -- Can you think of a way? - Answer on the next slide. (_Hint:_ `tail` and `head`...) --- # Example 2: Combine CSVs (cont.) Let's try again. First delete the old file so we can start afresh. ```bash $ rm -f examples/meals/mealplan.csv ## delete old file ``` -- Here's our adapted gameplan: - First, create the new file by grabbing the header (i.e. top line) from any of the input files and redirecting it. No need for `touch` this time. - Next, loop over all the input files as before, but this time only append everything _after_ the top line. ```bash ## create a new CSV by redirecting the top line of any file $ head -1 examples/meals/monday.csv > examples/meals/mealplan.csv ## loop over the input files, appending everything after the top line $ for i in $(ls examples/meals/*day.csv) > do > tail -n +2 $i >> examples/meals/mealplan.csv > done ``` --- # Example 2: Combine CSVs (cont.) It worked! ```bash $ cat examples/meals/mealplan.csv ``` ``` ## day,breakfast,lunch,dinner ## friday,pancakes,ramen,stew ## monday,muesli,sandwich,pasta ## saturday,muesli,sandwich,pad thai ## sunday,muesli,roast,leftovers ## thursday,muesli,salad,tacos ## tuesday,muesli,soup,roast ## wednesday,muesli,sandwich,pizza ``` -- We still have to sort the correct week order, but that's an easy job in R (or Stata, Python, etc.) - The explicit benefit of doing the concatenating in the shell is it is _much_ more efficient, since all the files don't simultaneously have to be held in memory (i.e RAM). - This doesn't matter here, but can make a dramatic difference once we start working with lots of files (or even a few really big ones). We'll revisit this idea later in the big data section of the course. --- class: inverse, center, middle name: scripting # Scripting <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> --- # Hello World! Writing code and commands interactively in the shell makes a lot of sense when you are exploring data, file structures, etc. However, it's also possible (and often desirable) to write reproducible shell scripts that combine a sequence of commands. - These scripts are demarcated by their `.sh` file extension. -- Let's look at the contents of a short shell script that I've included in the examples folder. ```bash $ cat examples/hello.sh ``` ``` ## #!/bin/sh ## echo -e "\nHello World!\n" ``` -- I'm sure that you already have a good idea of what this script is meant to do, but it will prove useful to quickly go through some things together. --- # Hello World! (cont.) ```bash *#!/bin/sh echo -e "\nHello World!\n" ``` - `#!/bin/sh` is a [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix), indicating which program to run the command with (here: any Bash-compatible shell). However, it is typically ignored (note that it begins with the hash comment character.) --- count: false # Hello World! (cont.) ```bash #!/bin/sh *echo -e "\nHello World!\n" ``` - `#!/bin/sh` is a [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix), indicating which program to run the command with (here: any Bash-compatible shell). However, it is typically ignored (note that it begins with the hash comment character.) - `echo -e "\nHello World!\n"` is the actual command that we want to run. --- count: false # Hello World! (cont.) ```bash #!/bin/sh echo -e "\nHello World!\n" ``` - `#!/bin/sh` is a [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix), indicating which program to run the command with (here: any Bash-compatible shell). However, it is typically ignored (note that it begins with the hash comment character.) - `echo -e "\nHello World!\n"` is the actual command that we want to run. The `-e` flag tells bash that we want to evaluate an expression rather than a file. To run this simple script, you can just type in the file name and press enter. ```bash $ examples/hello.sh $ # bash examples/hello.sh ## Also works ``` ``` ## ## Hello World! ``` --- name: rscript # Rscript It's important to realise that we aren't limited to running shell scripts in the shell. The exact same principles carry over to other programs and files. The most relevant case for this class is the [`Rscript`](https://stat.ethz.ch/R-manual/R-devel/library/utils/html/Rscript.html) command for (you guessed it) executing R scripts and expressions. For example: ```bash $ Rscript -e "cat('Hello World, from R!')" ``` ``` ## Hello World, from R! ``` -- Of course, the more typical `Rscript` use case is to execute full length R scripts. An optional, but very useful feature here is the ability to pass extra arguments from the shell to your R script. Consider the `hello.R` script that I've bundled in the examples folder. ```bash $ cat examples/hello.R ``` ``` ## args = commandArgs(trailingOnly = TRUE) ## i = args[1]; j = args[2] ## ## cat('Hello World, from R!\n', ## i, '+', j, '=', as.integer(i) + as.integer(j)) ``` --- # Rscript (cont.) The key step for using additional `Rscript` arguments is held within the top two lines. ```r args = commandArgs(trailingOnly = TRUE) i = args[1]; j = args[2] ``` These tell Rscript to capture any trailing arguments (i.e. after the file name) and then pass them on as objects that can be used within R. -- Let's run the script to see it in action. ```bash $ Rscript examples/hello.R 12 9 ``` ``` ## Hello World, from R! ## 12 + 9 = 21 ``` -- Again, including trailing arguments is entirely optional. You could run `Rscript myfile.R` without any problems. But it often proves very useful for the type of work that you'd likely be using `Rscript` for (e.g. batching big jobs). --- # Editing and writing scripts in the shell Say you want to edit my (amazing) `hello.sh` script. - Maybe you want to add some additional lines of text, or maybe you're bothered by the fact that there should be a comma after "Hello". (It's a salutation!) We have already seen how to append text lines to a file. But when it comes to more complicated editing work, you're better off using a dedicated shell editor. - I use [**vim**](https://missing.csail.mit.edu/2020/editors/). Extremely powerful, but a steep learning curve. - An easier starting point is [**nano**](https://www.nano-editor.org/). (**Windows users**, see [here](https://stackoverflow.com/questions/36802996/bash-nano-command-not-found-at-windows-git-bash).) Open up my script in nano by typing `$ nano examples/hello.sh`. - Note that the functionality is more limited than a normal text editor. - Once you are finished editing, hit "Ctrl+X", then "y" and enter to exit. - Finally, run the edited version of the script. -- If you've been having trouble executing this script (or want to limit who else can execute it), then you need to alter its permissions. Which takes us neatly on to our final section... --- class: inverse, center, middle name: permissions # User roles and file permissions <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> --- # Disclaimer *This next section is tailored towards Unix-based operating systems, like Linux or MacOS, which is why I have saved it for the end. <b>Windows users:</b> Don't be suprised if some commands don't work, especially if you haven't installed the [WSL](#windows)...* *Regardless, the things we learn here will become relevant to everyone (even Windows users) once we start interacting with Linux servers, spinning up Docker containers, etc. later in the course.* --- # The superuser: root, sudo, etc. There are two main user roles on a Linux system: 1. Normal users 2. A superuser (AKA "root") Difference is one of priviledge. - Superusers can make system changes, install software, browse through different users' home folders, etc. Normal users are much more restricted in what they can do. - Explains why Unix-based OS's are much more resilient to security threats like viruses. Need superuser priviledges to install (potentially malicious) software. --- # The superuser: root, sudo, etc. (cont.) You *can* log in as the superuser<sup>1</sup>... but this is generally considered very poor practice, since you needlessly risk messing up your system. - There are no safety checks and no "undo" options. .footnote[ <sup>1</sup> Hit "p" on this slide if you really want to know how. ] ??? To switch over to the superuser, you can type `sudo -s`. - Note the extra visual cue: root's command prompt is a `#` (not a `$`). ``` root@laptop:~# ``` Remember to type `exit` to switch back! (Close these presenter notes by hitting "p" again.) -- **Question:** How, then, can normal users perform meaningful system operations (including installing new programs and updating software)? -- **Answer:** Invoke temporary superuser status with `sudo`. - Stands for "superuser do". - Simply prepend `sudo` to whatever command you want to run. ```bash grant@laptop:~$ ls /root ## fails grant@laptop:~$ sudo ls /root ## works ``` ??? Note that you have to be a "permitted" user to invoke `sudo`. - This should be enabled by default on your personal laptop, but if not see [here](https://www.thegeekstuff.com/2010/09/sudo-command-examples/embed/) or [here](https://www.digitalocean.com/community/tutorials/how-to-create-a-sudo-user-on-ubuntu-quickstart). --- # Changing permissions and ownership Let's think back to the `ABC/` directory that we saw previously while exploring the ls command. ```bash drwxr-xr-x 2 grant users 4.0K Jan 12 22:12 ABC ``` We can change the permissions and ownership of this folder with the `chmod` and `chown` commands, respectively. We'll now review these in turn. - Note that I'm going to use the "recursive" option (i.e. `-R`) in the examples that follow, but only because `ABC/` is a directory. You can drop that when modifying individual files. -- PS — I'm going to skip writing out the full path for this next section to save on typing. Now is a a good time to move into the `examples/` directory if you want to follow along with my commands literally. ```bash $ cd examples ``` --- # chmod Changing permissions using `chmod` depends on how those permissions are represented. There are two options: 1) Octal notation and 2) Symbolic notation. - We'll go into more detail on the next slide, but let's see some examples first. - (Test the results yourself using the `ls -lh` command afterwards.) -- **Example 1: rwxrwxrwx.** Read, write and execute permission for all users. - Octal: `$ chmod -R 777 ABC` - Symbolic: `$ chmod -R a=rwx ABC` -- **Example 2: rwxr-xr-x.** Read, write and execute permission for the main user (i.e. owner) of the file. For all other users, read and execute permission only. - Octal: `$ chmod -R 755 ABC` - Symbolic: `$ chmod -R u=rwx,g=rx,o=rx ABC` -- Now that we've seen some examples, let's get into the logic behind them. --- # chmod (cont.) ### Octal notation Takes advantage of the fact that `4` (for "read"), `2` (for "write"), and `1` (for "execute") can be combined in unambiguous ways. - 7 (= 4 + 2 + 1) means read, write and execute permission. - 5 (= 4 + 0 + 1) means read and execute permission, but not write permission. - etc. - Note that Octal notation requires a number for each of the three user types: owner, owner's group, and all others. E.g. `$ chmod 777 myfile.txt` ### Symbolic notation Links permissions to different symbols (i.e. abbreviations). - Users: `u` ("User/owner"), `g` ("Group"), `o` ("Others""), `a` ("All") - Permissions: `r` ("read"), `w` ("write"), `x` ("execute") - Changes: `+` ("add permissions"), `-` ("remove permissions"), `=` ("set new permissions") --- # chmod (cont.) Here's a quick comparison table with some common permission levels. | Octal value | Symbolic value | Permission level | |:-----------:|:-----------------:|:----------------:| | 777 | a+rwx | rwxrwxrwx | | 770 | u+rwx,g+rwx,o-rwx | rwxrwx--- | | 755 | a+rwx,g=rw,o=rw | rwxrwxrwx | | 700 | u+rwx,g-rwx,o-rwx | rwx------ | | 644 | u=rw,g=r,o=r | rw-r--r-- | -- </br> PS — Note the Symbolic method allows for relative changes, which means that you don't necessarily need to write out the whole entry in the table above. E.g. To go from the first line to the second line, you'd only need `$ chmod o-rwx myfile`. --- # chown Changing file ownership is somewhat easier than changing permissions, because you don't have to remember the different Octal and Symbolic notation mappings. - E.g. Say there is another user on your computer called "alice", then you could just assign her ownership of the ABC subfolder using: ```bash $ chown -R alice ABC ``` Things get a little more interesting when we want to add new users and groups, or change an existing users group. - I'll save that for a later lecture on cloud servers, though. --- class: inverse, center, middle name: steps # Next steps <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> --- # Things we didn't cover today I know we covered a _lot_ of ground today. I hope that I've given you a sense of how Bash works and how powerful it is. - My main goal has been to "demystify" the shell, so that you aren't intimidated when we use shell commands later on. At the same time, there's loads that we didn't cover. - Environment variables, SSH, memory management (e.g. [top](https://ss64.com/bash/top.html) and [htop](https://hisham.hm/htop/)), GNU parallel, etc. - We'll get to some of these topics in the later lectures, but please try to work some of the suggested exercises on the next slide and make use of the recommended readings. --- # Next steps ### Exercises Navigate to the `examples/` sub-directory associated with this lecture. I want you to play around with the contents using some of the different Bash commands we practiced today. - Change the permissions on an indivdual file or a whole directory. - Read in (or fix) some lines of text from one file and pipe them to another file. - Count the number of times Shakespeare refers to "mistress" or "love" in his Sonnets. - Write a new bash script and execute it. - Etc. ### Further reading - [The Unix Shell](http://swcarpentry.github.io/shell-novice/) (Software Carpentery) - [The Unix Workbench](https://seankross.com/the-unix-workbench/) (Sean Kross) - [Data Science at the Command Line](https://www.datascienceatthecommandline.com/) (Jeroen Janssens) - [Using AWK and R to parse 25tb](https://livefreeordichotomize.com/2019/06/04/using_awk_and_r_to_parse_25tb/) (Nick Strayer) --- class: inverse, center, middle # Next class: *R* language basics <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> --- class: inverse, center, middle name: windows # Appendix (Windows users only) <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> --- # Bash on Windows Windows users have two options: ### 1. [Git Bash](https://gitforwindows.org/) - **Pros:** You should already have installed this as part of the previous lecture. - **Cons:** Functionality is limited to Git-related commands, so various things that we're going to practice today won't work. ### 2. [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/install-win10) - **Pros:** A self-contained Linux image (terminal) that allows full Bash functionality. - **Cons:** Must be installed first and only available to Windows 10 users. I'm going to go out on a limb and recommend option 2 (WSL) if available to you. It's more overhead, but I think worth it. See the next two slides for instructions and tips... .footnote[(Back to [table of contents](#toc).)] --- name:wsl # WSL The basic WSL installation guide is [**here**](https://docs.microsoft.com/en-us/windows/wsl/install-win10). - Follow the guide to install your preferred Linux distro. [Ubuntu](https://www.microsoft.com/en-us/p/ubuntu/9nblggh4msv6) is a good choice. - Then, once you've restarted your PC, come back to these slides. After installing your chosen WSL, you need to navigate to today's lecture directory to run the examples. You have two options: #### Option (i) Access WSL through RStudio (*recommended*) If you access WSL through RStudio, then it will conveniently configure your path to the present working directory. So, here's how to make WSL your default [RStudio Terminal](https://support.rstudio.com/hc/en-us/articles/115010737148-Using-the-RStudio-Terminal): - In RStudio, navigate to: *Tools > Terminal > Terminal Options...*. \[[Screenshot](pics/wsl-rstudio-1.png).\] - Click on the dropdown menu for *New terminals open with* and select "Bash (Windows Subsystem for Linux)", Then click *OK*. \[[Screenshot](pics/wsl-rstudio-2.png).\] - Refresh your RStudio terminal (`Alt+Shift+R`). \[[Screenshot](pics/wsl-rstudio-3.png).\] - You should see the WSL Bash environment with the path automatically configured to the present working director, mount point and all. \[[Screenshot](pics/wsl-rstudio-4.png).\] --- name: wsl-rstudio # WSL (cont.) #### Option (ii) Go directly through the WSL Presumably, you've cloned the course repo somewhere on your C drive. - The way this work is that Windows drives are mounted on the WSL's `mnt` directory. (More [here](https://www.howtogeek.com/261383/how-to-access-your-ubuntu-bash-files-in-windows-and-your-windows-system-drive-in-bash/).) - Say you cloned the repo to "C:\\Users\\Grant\\ec607\\lectures". - The WSL equivalent is "/mnt/c/Users/Grant/ec607/lectures". - So, then you can navigate to today's lecture through the WSL with: `$ cd /mnt/c/Users/Grant/ec607/lectures/03-shell`. Adjust as needed. .footnote[(Back to [table of contents](#toc).)] -- ### Which option to choose? Both are fine, but I recommend option **(i)**. As a Windows user, being able to access a true Bash shell (i.e. terminal) conveniently from RStudio will make things *much* easier for you in my class. You can always revert back to a different shell later if you want.