├── ed1.go ├── users.csv ├── awk1.go ├── ed2.go ├── sed1.go ├── LICENSE ├── README.md └── romeo_and_juliet.txt /ed1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | var count = 0 6 | 7 | func increment() { 8 | c++ 9 | } 10 | 11 | func main() { 12 | ingrement() 13 | ingrement() 14 | fmt.Println(count) 15 | } 16 | -------------------------------------------------------------------------------- /users.csv: -------------------------------------------------------------------------------- 1 | Name,Age,Gender,ID 2 | Tom Smith,20,Male,2DDB9DF2-D793-4A9A-BE42-81D1AAF02001 3 | Jim Smith,22,Male,2BAF49D0-FC10-428F-A409-BF9482227B6D 4 | Ann Cameron,21,Female,521ED759-3F6A-4926-8865-C500550FDFAE 5 | Tim Cameron,32,Male,2AA082C3-5BAE-4C63-B9FB-670E86A67963 6 | Cate Cameron,24,Female,E00DCE81-0690-498D-A4D2-FD74F3EDEAEF 7 | -------------------------------------------------------------------------------- /awk1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func hello() { 6 | fmt.Brintln("Hello, world!"); fmt.Brintln("Hello, ed!") 7 | fmt.Brintln("Hello, world!"); fmt.Brintln("Hello, ed!") 8 | fmt.Brintln("Hello, world!"); fmt.Brintln("Hello, ed!") 9 | fmt.Brintln("Hello, world!"); fmt.Brintln("Hello, ed!") 10 | } 11 | 12 | func main() { 13 | hollo() 14 | } 15 | -------------------------------------------------------------------------------- /ed2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func hello() { 6 | fmt.Brintln("Hello, world!"); fmt.Brintln("Hello, ed!") 7 | fmt.Brintln("Hello, world!"); fmt.Brintln("Hello, ed!") 8 | fmt.Brintln("Hello, world!"); fmt.Brintln("Hello, ed!") 9 | fmt.Brintln("Hello, world!"); fmt.Brintln("Hello, ed!") 10 | } 11 | 12 | func main() { 13 | hollo() 14 | } 15 | -------------------------------------------------------------------------------- /sed1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func hello() { 6 | fmt.Brintln("Hello, world!"); fmt.Brintln("Hello, ed!") 7 | fmt.Brintln("Hello, world!"); fmt.Brintln("Hello, ed!") 8 | fmt.Brintln("Hello, world!"); fmt.Brintln("Hello, ed!") 9 | fmt.Brintln("Hello, world!"); fmt.Brintln("Hello, ed!") 10 | } 11 | 12 | func main() { 13 | hollo() 14 | } 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021-present syumai 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # sed & awk ハンズオン 2 | 3 | ## 全体の流れ 4 | 5 | * 1. edハンズオン 6 | * 2. sedハンズオン 7 | * 3. awkハンズオン 8 | 9 | ## edハンズオン 10 | 11 | sed / awkの使い方を説明するにあたって、まず `ed` コマンドについて知っていただく必要があります。 12 | 13 | `ed` は著名なラインエディタで、これをベースとしてsedやex & vimなどが開発されました。 14 | 15 | ### edの基本的な使い方 16 | 17 | ファイルを開くと、対話型のエディタが開きます。 18 | 19 | ``` 20 | ed ファイル名 21 | ``` 22 | 23 | 試しに、 `ed romeo_and_juliet.txt` と入力してみると、まずファイル内の文字数が表示されます。 24 | これだけでは、何が起こっているかわからないので、ファイルの中身を探索してみましょう。 25 | 26 | ``` 27 | 1p 28 | ``` 29 | 30 | と入力すると、1行目の内容が表示されます。 31 | 32 | ``` 33 | 2p 34 | ``` 35 | 36 | と入力すると、2行目の内容が表示されます。 37 | 38 | ここでの `1`, `2` はファイル内の固有の位置を示すアドレスとなっており、その後にコマンド名 `p` が続いています。 39 | `p` は、指定されたアドレスの内容を出力するコマンドなので、上記のような挙動になっていました。 40 | 41 | **最初のポイント** 42 | 43 | ``` 44 | edへの命令は、 `アドレス+コマンド` で構成されている 45 | ``` 46 | 47 | また、コマンドを実行すると、処理中の行が移動します。 48 | また、アドレスはOptionalなので、コマンドのみで実行可能です。 49 | `2p` を実行した後に `p` を実行すると、処理中の行が2行目に移っているので、その行が出力されることがわかります。 50 | 51 | ### アドレスの使い方 52 | 53 | アドレスには複数種類があります。よく使いそうなものを挙げておきます。 54 | 55 | #### 数値アドレス 56 | 57 | * `1`, `2` などの数値で行番号を指定します 58 | 59 | #### 正規表現アドレス 60 | 61 | * `/Romeo/` などの正規表現で行を指定します 62 | 63 | #### その他のアドレス 64 | 65 | * `.` => 現在の行 66 | * `$` => 最後の行 67 | * `-` => 直前の行 68 | * `-n` => n個前の行 69 | * `+` => 直後の行 70 | * `+n` => n個後の行 71 | 72 | `man ed` にわかりやすく書かれているので、困ったら参照してみてください。 73 | 74 | ### 正規表現アドレスを使う 75 | 76 | `/Romeo/p` と入れてみてください。 77 | すると、次にヒットする `Romeo` の行が表示されます。何度か試しに実行してみてください。(/Rom/くらいでいけます) 78 | 79 | ### 範囲アドレス 80 | 81 | 2つのアドレスを `,` でつなぐことで使えます。 82 | 83 | `1,3p` と入れれば 1~3行目がprintされる 84 | `1,$p` と入れれば 1行目から最終行までがprintされる 85 | `2,/Romeo/p` と入れれば、1行目から次のRomeoまでがprintされる 86 | `/ROMEO/,/JULIET/p` と入れれば、次のROMEOからその次のJULIETまでがprintされる 87 | 88 | ### コマンドを使う 89 | 90 | `p` コマンドしか登場しませんでしたが、ここでいくつか追加のコマンドを紹介します。 91 | 92 | #### 迷った時に使えるコマンド 93 | 94 | * `=` => 指定した位置のアドレスを表示する。 `.=` と入れると現在位置のアドレスが見られて便利。 95 | * `n` => 行番号付きでprintする。めちゃめちゃ便利。 96 | * `h` => 直前のエラー内容を出力する。`?` が出た時に使う。 97 | * `H` => `h` を入力しなくても常にエラー内容を出力する 98 | - 起動時に `H` を打っておくのがおすすめ 99 | 100 | #### 置換でめちゃめちゃ使うコマンド 101 | 102 | * s/re/re/ => 正規表現での置換。アドレスで指定された行内で初めてマッチした正規表現の対象を置き換える。 103 | * s/re/re/g => 正規表現でのグローバルな置換。アドレスで指定された行内でマッチした全ての正規表現の対象を置き換える。 104 | 105 | 例) /Romeo/ を /Hoge/ に置き換えてみる 106 | 107 | `54p` と入力してみましょう。 108 | 109 | すると、 `O Romeo, Romeo! wherefore art thou Romeo?` と言う `Romeo` が3回登場する行が見つかります。 110 | 111 | ここで、 `54s/Romeo/Hoge/` と入力してみましょう。 112 | 113 | 結果を `p` で確認すると、 `O Hoge, Romeo! wherefore art thou Romeo?` に変更されていることがわかります。 114 | 115 | 次に、グローバル置換を紹介します。 116 | 117 | `54s/Romeo/Hoge/g` を実行してみましょう。 118 | 119 | 結果を `p` で確認すると、行内のRomeoが全て置き換えられ、 `O Hoge, Hoge! wherefore art thou Hoge?` に変更されていることがわかります。 120 | 121 | #### Viを彷彿とさせるコマンド 122 | 123 | * `i` => 挿入。アドレスで指定された行に文字列を挿入する。範囲指定可能。実行するとInsert modeに入る。 124 | * `a` => 追加。次の行に文字列を追加する。実行するとInsert modeに入る。 125 | * `d` => 削除。アドレスで指定された行を削除する。範囲指定可能 126 | * `c` => 変更。アドレスで指定された行を置き換える。範囲指定可能。実行するとInsert modeに入る。 127 | * `u` => 直前の操作を取り消す。 128 | * `w` => 保存する 129 | * `q` => エディタを終了する 130 | 131 | Insert modeからは ^C で抜けることが出来ます。 132 | Insert mode中では、複数行のテキストを入力可能で、あくまで行単位での編集となるので、行が挿入、追加、置換(変更)されることになります。 133 | 134 | ed にはこれだけのコマンドが揃っているので、一通りのテキスト編集が実施可能です。 135 | それでは、実際にコードを編集してみましょう。 136 | 137 | `ed ed1.go` 138 | 139 | 編集した `wq` で保存した結果、 `go run ed1.go` が通るようになればOKです。 140 | 141 | 新規でファイルを作成したい場合は、 142 | `ed ファイル名` でファイルを作成し、 `i` で内容を挿入して `wq` で抜ければOKです。 143 | 144 | ### グローバルコマンドを使う 145 | 146 | edの命令は `アドレス+コマンド` で実行できると言う話をしました。 147 | 実は、グローバルコマンド `g/re/command-list` を使うと、ファイル全体の行に対してコマンドを実行できるという、コマンドを受け取るコマンドがあります。 148 | これは、特にファイル全体でマッチする正規表現を置き換えたい時に便利です。 149 | 150 | 次のファイルを編集してみてください。 151 | 152 | `ed ed2.go` 153 | 154 | 地獄のような内容になっているかと思います。 155 | 156 | これを実行できるようにするには、 `Brintln` を全て `Println` に置き換える必要があります。 157 | ここで、 `g/Brintln/s/Brintln/Println/g` を実行すると、全ての `Brintln` を `Println` に置き換えることが出来ます。 158 | 省略記法として、 `g/Brintln/s//Println/g` も使うことが出来ます。 159 | 160 | あとはプログラムに問題のある箇所があるので、それを修正して `go run ed2.go` が動くことを確認してみてください。 161 | 162 | ### 小話 163 | 164 | `grep` コマンドの名前の由来は、edコマンドの `g/re/p` らしいです。 165 | `echo 'g/Romeo/p' | ed -s romeo_and_juliet.md` してみると、なるほど感が得られると思います。 166 | 167 | ### さらに小話 168 | 169 | `1,$` のrangeに対するエイリアスとして `%` が存在します。 170 | `%p` と実行すると、ファイル全体を表示することが出来ます。 171 | ここで、これを使って、ファイル全体の中でマッチする表現を置換するコマンドを実行しようとすると、 172 | `%s/Romeo/Juliet/g` といった形になります。 173 | この形式のコマンドに見覚えのある方も多いのではないでしょうか? (Vimでよく使う置換コマンドです) 174 | 175 | ## sedハンズオン 176 | 177 | ついにここでsedに入ります。 178 | 179 | 説明をかなりサボってしまいますが、 `sedはほぼedです`。 180 | 違いは、edが行単位での編集を志向するツールである一方、sedはファイル単位の編集を志向しているところです。 181 | 182 | もう一つの違いは、edがアドレスを操作対象の指定に使っていた一方で、sedはアドレスを操作対象の絞り込みに使っているところです。 183 | edでは、アドレスを指定しないと編集操作が出来ませんでした。sedでは、全行が操作対象になってしまうので、それを避けるためにアドレス指定を利用します。 184 | 185 | 実際に使ってみるのが早いのでやってみましょう。 186 | 187 | sedの使い方は簡単です。 188 | edの命令部を引数として与え、それを適用するファイルを指定するだけです。 189 | 190 | `sed '' sed1.go` 191 | 192 | sedは、デフォルトで操作結果の行を全てprintするようになっているので、空の命令を与えると全行がそのまま出力されます。 193 | 194 | これを抑制したい場合は、 `sed -n` を使います。 195 | 196 | `sed -n '' sed1.go` 197 | 198 | は何も表示しませんが、 199 | 200 | `sed -n 'p' sed1.go` 201 | 202 | は全行を表示します。edっぽさが顔を出しましたね。 203 | 204 | 続いて、 `Brintln` の置換操作をしてみましょう。 205 | 206 | `sed 's/Brintln/Println/' sed1.go` 207 | 208 | を実行すると、行にマッチした1つ目のBrintlnが置き換えられ、 209 | 210 | `sed 's/Brintln/Println/g' sed1.go` 211 | 212 | を実行すると、行にマッチした全てのBrintlnが置き換えられることがわかります。 213 | 214 | 次に、アドレスを使ってみましょう。 215 | 216 | `sed '6,7s/Brintln/Println/g' sed1.go` 217 | 218 | を実行すると、6~7行目のBrintlnだけがPrintlnに置き換えられます。 219 | 220 | `sed '6,7d' sed1.go` 221 | 222 | を実行すると、2~4行目が削除されます。 223 | 224 | sedへの命令は複数渡すことが出来ます。 225 | 226 | `sed '6,7s/Brintln/Println/g;8,9s/Hello/Hoge/g' sed1.go` 227 | 228 | のように `;` 繋ぎで命令を書くと、6~7行目のBrintlnがPrintlnに、8~9行目のHelloがHogeに置き換えられます。 229 | 230 | と言う形で、edのアドレス&コマンドの操作をそのままファイル単位で使えるのがsedという事が伝わったかと思います。 231 | (実際には、使えないコマンドもかなり多いようです。sedの方がコマンドが少ない…。) 232 | 233 | 最後に、 `sed1.go` を修正した結果を `sed1-ans.go` に出力して `go run sed1-ans.go` が実行できたら完了です。 234 | 235 | `sed '???' sed1.go > sed1-ans.go` 236 | 237 | ## awkハンズオン 238 | 239 | awkも、sedと同様なファイル単位での編集を志向するツールです。 240 | 大きな違いは、awkがプログラミング言語として実装されており、より高度な操作が出来ることです。 241 | 構文的にもプログラミング言語と感じられる見た目をしています。 242 | 243 | 下記のコマンドを実行してみてください。 244 | 245 | `awk '{print}' awk1.go` 246 | 247 | awkは、明示的にprintを行うよう指定しないと、何も出力しません。 248 | 249 | `awk '' awk1.go` 250 | 251 | アドレスについては、正規表現アドレスはed / sedと共通です。 252 | 253 | `awk '/Brintln/{print}' awk1.go` 254 | 255 | awkは、 ` ` をセパレータとして、入力を分割する機能を持ちます。 256 | 257 | `awk '{ print $0 }' awk1.go` 258 | 259 | は行全体、 260 | 261 | `awk '{ print $1 }' awk1.go` 262 | `awk '{ print $2 }' awk1.go` 263 | 264 | はスペース区切りです。 265 | 266 | セパレータを変えるには、 `-F` を使います。 267 | `-F,` とすると、 `,` がセパレータになります。 268 | 269 | `awk -F, '{ print $0 }' users.csv` 270 | 271 | は行全体、 272 | 273 | `awk -F, '{ print $1 }' users.csv` 274 | `awk -F, '{ print $2 }' users.csv` 275 | 276 | は,区切りです。 277 | 278 | これを使って、クエリの生成などを行ってみてもよいでしょう。 279 | 280 | `awk -F, '{ printf("UPDATE Users SET...", $0, $1...)}` 281 | 282 | 例題として、IDのみを出力するawkコマンドを書いて、 `user_ids.csv` に出力してみてください。 283 | -------------------------------------------------------------------------------- /romeo_and_juliet.txt: -------------------------------------------------------------------------------- 1 | // This text is from http://shakespeare.mit.edu/romeo_juliet/romeo_juliet.2.2.html 2 | // The original electronic source for this text was the Complete Moby(tm) Shakespeare. 3 | 4 | SCENE II. Capulet's orchard. 5 | 6 | Enter ROMEO 7 | 8 | ROMEO 9 | 10 | He jests at scars that never felt a wound. 11 | JULIET appears above at a window 12 | But, soft! what light through yonder window breaks? 13 | It is the east, and Juliet is the sun. 14 | Arise, fair sun, and kill the envious moon, 15 | Who is already sick and pale with grief, 16 | That thou her maid art far more fair than she: 17 | Be not her maid, since she is envious; 18 | Her vestal livery is but sick and green 19 | And none but fools do wear it; cast it off. 20 | It is my lady, O, it is my love! 21 | O, that she knew she were! 22 | She speaks yet she says nothing: what of that? 23 | Her eye discourses; I will answer it. 24 | I am too bold, 'tis not to me she speaks: 25 | Two of the fairest stars in all the heaven, 26 | Having some business, do entreat her eyes 27 | To twinkle in their spheres till they return. 28 | What if her eyes were there, they in her head? 29 | The brightness of her cheek would shame those stars, 30 | As daylight doth a lamp; her eyes in heaven 31 | Would through the airy region stream so bright 32 | That birds would sing and think it were not night. 33 | See, how she leans her cheek upon her hand! 34 | O, that I were a glove upon that hand, 35 | That I might touch that cheek! 36 | 37 | JULIET 38 | 39 | Ay me! 40 | 41 | ROMEO 42 | 43 | She speaks: 44 | O, speak again, bright angel! for thou art 45 | As glorious to this night, being o'er my head 46 | As is a winged messenger of heaven 47 | Unto the white-upturned wondering eyes 48 | Of mortals that fall back to gaze on him 49 | When he bestrides the lazy-pacing clouds 50 | And sails upon the bosom of the air. 51 | 52 | JULIET 53 | 54 | O Romeo, Romeo! wherefore art thou Romeo? 55 | Deny thy father and refuse thy name; 56 | Or, if thou wilt not, be but sworn my love, 57 | And I'll no longer be a Capulet. 58 | 59 | ROMEO 60 | 61 | [Aside] Shall I hear more, or shall I speak at this? 62 | 63 | JULIET 64 | 65 | 'Tis but thy name that is my enemy; 66 | Thou art thyself, though not a Montague. 67 | What's Montague? it is nor hand, nor foot, 68 | Nor arm, nor face, nor any other part 69 | Belonging to a man. O, be some other name! 70 | What's in a name? that which we call a rose 71 | By any other name would smell as sweet; 72 | So Romeo would, were he not Romeo call'd, 73 | Retain that dear perfection which he owes 74 | Without that title. Romeo, doff thy name, 75 | And for that name which is no part of thee 76 | Take all myself. 77 | 78 | ROMEO 79 | 80 | I take thee at thy word: 81 | Call me but love, and I'll be new baptized; 82 | Henceforth I never will be Romeo. 83 | 84 | JULIET 85 | 86 | What man art thou that thus bescreen'd in night 87 | So stumblest on my counsel? 88 | 89 | ROMEO 90 | 91 | By a name 92 | I know not how to tell thee who I am: 93 | My name, dear saint, is hateful to myself, 94 | Because it is an enemy to thee; 95 | Had I it written, I would tear the word. 96 | 97 | JULIET 98 | 99 | My ears have not yet drunk a hundred words 100 | Of that tongue's utterance, yet I know the sound: 101 | Art thou not Romeo and a Montague? 102 | 103 | ROMEO 104 | 105 | Neither, fair saint, if either thee dislike. 106 | 107 | JULIET 108 | 109 | How camest thou hither, tell me, and wherefore? 110 | The orchard walls are high and hard to climb, 111 | And the place death, considering who thou art, 112 | If any of my kinsmen find thee here. 113 | 114 | ROMEO 115 | 116 | With love's light wings did I o'er-perch these walls; 117 | For stony limits cannot hold love out, 118 | And what love can do that dares love attempt; 119 | Therefore thy kinsmen are no let to me. 120 | 121 | JULIET 122 | 123 | If they do see thee, they will murder thee. 124 | 125 | ROMEO 126 | 127 | Alack, there lies more peril in thine eye 128 | Than twenty of their swords: look thou but sweet, 129 | And I am proof against their enmity. 130 | 131 | JULIET 132 | 133 | I would not for the world they saw thee here. 134 | 135 | ROMEO 136 | 137 | I have night's cloak to hide me from their sight; 138 | And but thou love me, let them find me here: 139 | My life were better ended by their hate, 140 | Than death prorogued, wanting of thy love. 141 | 142 | JULIET 143 | 144 | By whose direction found'st thou out this place? 145 | 146 | ROMEO 147 | 148 | By love, who first did prompt me to inquire; 149 | He lent me counsel and I lent him eyes. 150 | I am no pilot; yet, wert thou as far 151 | As that vast shore wash'd with the farthest sea, 152 | I would adventure for such merchandise. 153 | 154 | JULIET 155 | 156 | Thou know'st the mask of night is on my face, 157 | Else would a maiden blush bepaint my cheek 158 | For that which thou hast heard me speak to-night 159 | Fain would I dwell on form, fain, fain deny 160 | What I have spoke: but farewell compliment! 161 | Dost thou love me? I know thou wilt say 'Ay,' 162 | And I will take thy word: yet if thou swear'st, 163 | Thou mayst prove false; at lovers' perjuries 164 | Then say, Jove laughs. O gentle Romeo, 165 | If thou dost love, pronounce it faithfully: 166 | Or if thou think'st I am too quickly won, 167 | I'll frown and be perverse an say thee nay, 168 | So thou wilt woo; but else, not for the world. 169 | In truth, fair Montague, I am too fond, 170 | And therefore thou mayst think my 'havior light: 171 | But trust me, gentleman, I'll prove more true 172 | Than those that have more cunning to be strange. 173 | I should have been more strange, I must confess, 174 | But that thou overheard'st, ere I was ware, 175 | My true love's passion: therefore pardon me, 176 | And not impute this yielding to light love, 177 | Which the dark night hath so discovered. 178 | 179 | ROMEO 180 | 181 | Lady, by yonder blessed moon I swear 182 | That tips with silver all these fruit-tree tops-- 183 | 184 | JULIET 185 | 186 | O, swear not by the moon, the inconstant moon, 187 | That monthly changes in her circled orb, 188 | Lest that thy love prove likewise variable. 189 | 190 | ROMEO 191 | 192 | What shall I swear by? 193 | 194 | JULIET 195 | 196 | Do not swear at all; 197 | Or, if thou wilt, swear by thy gracious self, 198 | Which is the god of my idolatry, 199 | And I'll believe thee. 200 | 201 | ROMEO 202 | 203 | If my heart's dear love-- 204 | 205 | JULIET 206 | 207 | Well, do not swear: although I joy in thee, 208 | I have no joy of this contract to-night: 209 | It is too rash, too unadvised, too sudden; 210 | Too like the lightning, which doth cease to be 211 | Ere one can say 'It lightens.' Sweet, good night! 212 | This bud of love, by summer's ripening breath, 213 | May prove a beauteous flower when next we meet. 214 | Good night, good night! as sweet repose and rest 215 | Come to thy heart as that within my breast! 216 | 217 | ROMEO 218 | 219 | O, wilt thou leave me so unsatisfied? 220 | 221 | JULIET 222 | 223 | What satisfaction canst thou have to-night? 224 | 225 | ROMEO 226 | 227 | The exchange of thy love's faithful vow for mine. 228 | 229 | JULIET 230 | 231 | I gave thee mine before thou didst request it: 232 | And yet I would it were to give again. 233 | 234 | ROMEO 235 | 236 | Wouldst thou withdraw it? for what purpose, love? 237 | 238 | JULIET 239 | 240 | But to be frank, and give it thee again. 241 | And yet I wish but for the thing I have: 242 | My bounty is as boundless as the sea, 243 | My love as deep; the more I give to thee, 244 | The more I have, for both are infinite. 245 | Nurse calls within 246 | I hear some noise within; dear love, adieu! 247 | Anon, good nurse! Sweet Montague, be true. 248 | Stay but a little, I will come again. 249 | Exit, above 250 | 251 | ROMEO 252 | 253 | O blessed, blessed night! I am afeard. 254 | Being in night, all this is but a dream, 255 | Too flattering-sweet to be substantial. 256 | Re-enter JULIET, above 257 | 258 | JULIET 259 | 260 | Three words, dear Romeo, and good night indeed. 261 | If that thy bent of love be honourable, 262 | Thy purpose marriage, send me word to-morrow, 263 | By one that I'll procure to come to thee, 264 | Where and what time thou wilt perform the rite; 265 | And all my fortunes at thy foot I'll lay 266 | And follow thee my lord throughout the world. 267 | 268 | Nurse 269 | 270 | [Within] Madam! 271 | 272 | JULIET 273 | 274 | I come, anon.--But if thou mean'st not well, 275 | I do beseech thee-- 276 | 277 | Nurse 278 | 279 | [Within] Madam! 280 | 281 | JULIET 282 | 283 | By and by, I come:-- 284 | To cease thy suit, and leave me to my grief: 285 | To-morrow will I send. 286 | 287 | ROMEO 288 | 289 | So thrive my soul-- 290 | 291 | JULIET 292 | 293 | A thousand times good night! 294 | Exit, above 295 | 296 | ROMEO 297 | 298 | A thousand times the worse, to want thy light. 299 | Love goes toward love, as schoolboys from 300 | their books, 301 | But love from love, toward school with heavy looks. 302 | Retiring 303 | Re-enter JULIET, above 304 | 305 | JULIET 306 | 307 | Hist! Romeo, hist! O, for a falconer's voice, 308 | To lure this tassel-gentle back again! 309 | Bondage is hoarse, and may not speak aloud; 310 | Else would I tear the cave where Echo lies, 311 | And make her airy tongue more hoarse than mine, 312 | With repetition of my Romeo's name. 313 | 314 | ROMEO 315 | 316 | It is my soul that calls upon my name: 317 | How silver-sweet sound lovers' tongues by night, 318 | Like softest music to attending ears! 319 | 320 | JULIET 321 | 322 | Romeo! 323 | 324 | ROMEO 325 | 326 | My dear? 327 | 328 | JULIET 329 | 330 | At what o'clock to-morrow 331 | Shall I send to thee? 332 | 333 | ROMEO 334 | 335 | At the hour of nine. 336 | 337 | JULIET 338 | 339 | I will not fail: 'tis twenty years till then. 340 | I have forgot why I did call thee back. 341 | 342 | ROMEO 343 | 344 | Let me stand here till thou remember it. 345 | 346 | JULIET 347 | 348 | I shall forget, to have thee still stand there, 349 | Remembering how I love thy company. 350 | 351 | ROMEO 352 | 353 | And I'll still stay, to have thee still forget, 354 | Forgetting any other home but this. 355 | 356 | JULIET 357 | 358 | 'Tis almost morning; I would have thee gone: 359 | And yet no further than a wanton's bird; 360 | Who lets it hop a little from her hand, 361 | Like a poor prisoner in his twisted gyves, 362 | And with a silk thread plucks it back again, 363 | So loving-jealous of his liberty. 364 | 365 | ROMEO 366 | 367 | I would I were thy bird. 368 | 369 | JULIET 370 | 371 | Sweet, so would I: 372 | Yet I should kill thee with much cherishing. 373 | Good night, good night! parting is such 374 | sweet sorrow, 375 | That I shall say good night till it be morrow. 376 | Exit above 377 | 378 | ROMEO 379 | 380 | Sleep dwell upon thine eyes, peace in thy breast! 381 | Would I were sleep and peace, so sweet to rest! 382 | Hence will I to my ghostly father's cell, 383 | His help to crave, and my dear hap to tell. 384 | Exit 385 | 386 | --------------------------------------------------------------------------------