Last active
August 29, 2015 13:57
-
-
Save lancelakey/9573965 to your computer and use it in GitHub Desktop.
Playing with bash in the Mac OS X Terminal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is not a script | |
Simply type the stuff next to the ~ > into your Terminal like I did | |
Basically, we're playing around with doing a thing, and then with doing a thing several times | |
Play around with this for a few minutes, have fun with it, see if you can come up with your own variations | |
Homework, things to think about: | |
What does echo do? | |
What does for do? | |
What is {1..5}? | |
What does for i in {1..5} ; do SOMETHING ; done do? | |
What does curl do? | |
What does curl do without the curl -LI options? | |
What is a man page? | |
What does man curl do? Hint: Press q to exit a man page | |
References: | |
http://www.cyberciti.biz/faq/bash-for-loop/ | |
http://tldp.org/LDP/abs/html/loops1.html | |
~ > echo "Hello World" | |
Hello World | |
~ > for i in {1..5} ; do echo "Hello World $i" ; done | |
Hello World 1 | |
Hello World 2 | |
Hello World 3 | |
Hello World 4 | |
Hello World 5 | |
~ > for item in {1..5} ; do echo "Hello World $item" ; done | |
Hello World 1 | |
Hello World 2 | |
Hello World 3 | |
Hello World 4 | |
Hello World 5 | |
~ > for value in {1..5} ; do echo "Hello World $value" ; done | |
Hello World 1 | |
Hello World 2 | |
Hello World 3 | |
Hello World 4 | |
Hello World 5 | |
~ > for smurf in {1..5} ; do echo "Hello World $smurf" ; done | |
Hello World 1 | |
Hello World 2 | |
Hello World 3 | |
Hello World 4 | |
Hello World 5 | |
~ > curl -LI http://www.google.com | |
HTTP/1.1 200 OK | |
Date: Sat, 15 Mar 2014 21:05:33 GMT | |
Expires: -1 | |
Cache-Control: private, max-age=0 | |
Content-Type: text/html; charset=ISO-8859-1 | |
Set-Cookie: PREF=ID=dd8f904dc708639a:FF=0:TM=1394917533:LM=1394917533:S=B1e5wWIJD312CMKR; expires=Mon, 14-Mar-2016 21:05:33 GMT; path=/; domain=.google.com | |
Set-Cookie: NID=67=PJuSakUclgw5hjDaGWpKiffQpmEM9gg0_faRzMy7eY6n9T6M3T-WXRcxX8y7VLtChqaaSHDIKydciVKQkaqK9lP8LJYaVIwaXABg-Lzexd7Dj8FsgEQS9LhdZxtsJIoG; expires=Sun, 14-Sep-2014 21:05:33 GMT; path=/; domain=.google.com; HttpOnly | |
P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info." | |
Server: gws | |
X-XSS-Protection: 1; mode=block | |
X-Frame-Options: SAMEORIGIN | |
Alternate-Protocol: 80:quic | |
Transfer-Encoding: chunked | |
~ > for i in {1..5} ; do curl -LI http://www.google.com ; done | |
HTTP/1.1 200 OK | |
Date: Sat, 15 Mar 2014 21:05:42 GMT | |
Expires: -1 | |
Cache-Control: private, max-age=0 | |
Content-Type: text/html; charset=ISO-8859-1 | |
Set-Cookie: PREF=ID=a99b646a8ffe818f:FF=0:TM=1394917542:LM=1394917542:S=VyIs9tlKL9ikL8PH; expires=Mon, 14-Mar-2016 21:05:42 GMT; path=/; domain=.google.com | |
Set-Cookie: NID=67=DlbbmD9Y2SVZldKhB1woZ2L6c4GqY7bNU3gqUlDzyslYBhg75qx-Md5XlGgnZYZrxKjbs5USiWIFlOcbPj3zOH8tnw71z2onXLhTMcuGxk4SGokHWtiNlHZqVrwhxHW8; expires=Sun, 14-Sep-2014 21:05:42 GMT; path=/; domain=.google.com; HttpOnly | |
P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info." | |
Server: gws | |
X-XSS-Protection: 1; mode=block | |
X-Frame-Options: SAMEORIGIN | |
Alternate-Protocol: 80:quic | |
Transfer-Encoding: chunked | |
HTTP/1.1 200 OK | |
Date: Sat, 15 Mar 2014 21:05:42 GMT | |
Expires: -1 | |
Cache-Control: private, max-age=0 | |
Content-Type: text/html; charset=ISO-8859-1 | |
Set-Cookie: PREF=ID=f1d3efc4c48df754:FF=0:TM=1394917542:LM=1394917542:S=y9lauhD5mulZnWcY; expires=Mon, 14-Mar-2016 21:05:42 GMT; path=/; domain=.google.com | |
Set-Cookie: NID=67=BJYsi9FRF6648OUXhgXDNmBnhtET2HIOCBPcyBNOwfwr6Y9x-s-qHsuwGiRvDXogBsVBv70lWKAWccSKFRM4dHL7aaLmC0tzC4FO4HKuZ8xY5NXjt8raiBh47SmltYUO; expires=Sun, 14-Sep-2014 21:05:42 GMT; path=/; domain=.google.com; HttpOnly | |
P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info." | |
Server: gws | |
X-XSS-Protection: 1; mode=block | |
X-Frame-Options: SAMEORIGIN | |
Alternate-Protocol: 80:quic | |
Transfer-Encoding: chunked | |
HTTP/1.1 200 OK | |
Date: Sat, 15 Mar 2014 21:05:42 GMT | |
Expires: -1 | |
Cache-Control: private, max-age=0 | |
Content-Type: text/html; charset=ISO-8859-1 | |
Set-Cookie: PREF=ID=4df46034722efedd:FF=0:TM=1394917542:LM=1394917542:S=Me15fQSLeec1V_L7; expires=Mon, 14-Mar-2016 21:05:42 GMT; path=/; domain=.google.com | |
Set-Cookie: NID=67=h4XXESsMhUbaegIdr_2wldNUCVodU1vsd64TGxtwSALsByjr6RODf8tzqZjocaHqYxnxSmrUFG_SV39FPJSDxz9HrcGpWUITvObNzNF3gGq7-z_y3vN6MxZ3R2YCx24F; expires=Sun, 14-Sep-2014 21:05:42 GMT; path=/; domain=.google.com; HttpOnly | |
P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info." | |
Server: gws | |
X-XSS-Protection: 1; mode=block | |
X-Frame-Options: SAMEORIGIN | |
Alternate-Protocol: 80:quic | |
Transfer-Encoding: chunked | |
HTTP/1.1 200 OK | |
Date: Sat, 15 Mar 2014 21:05:42 GMT | |
Expires: -1 | |
Cache-Control: private, max-age=0 | |
Content-Type: text/html; charset=ISO-8859-1 | |
Set-Cookie: PREF=ID=66bdcaedf5077b27:FF=0:TM=1394917542:LM=1394917542:S=ERV089P-NDTDHfdl; expires=Mon, 14-Mar-2016 21:05:42 GMT; path=/; domain=.google.com | |
Set-Cookie: NID=67=HW1bMiu45GYZEL-4EANJ2zKy6V4zNyVPG3NUJ9lvYpixa2Zh6VF7bsBtWXIDVBTkA4wdisewj-gVSJipN2C7YU6BIpafAXPEn6zTxLfgVMnbzoBv7kHIQLdktZ0DixxI; expires=Sun, 14-Sep-2014 21:05:42 GMT; path=/; domain=.google.com; HttpOnly | |
P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info." | |
Server: gws | |
X-XSS-Protection: 1; mode=block | |
X-Frame-Options: SAMEORIGIN | |
Alternate-Protocol: 80:quic | |
Transfer-Encoding: chunked | |
HTTP/1.1 200 OK | |
Date: Sat, 15 Mar 2014 21:05:42 GMT | |
Expires: -1 | |
Cache-Control: private, max-age=0 | |
Content-Type: text/html; charset=ISO-8859-1 | |
Set-Cookie: PREF=ID=93a2bf1e2f91f47f:FF=0:TM=1394917542:LM=1394917542:S=t1fz-gVL561Wgsqp; expires=Mon, 14-Mar-2016 21:05:42 GMT; path=/; domain=.google.com | |
Set-Cookie: NID=67=dDmW2R3BPWnUYFnZKDM5b7w0Y7fMbTaadeqSFszCAQ9sAJtz_avDTYambyX7oUWirAsEPAl-45L-ImzAMGrdnVv2oOWQWjJmSMIjtGZ5zAsLBjstE0goAP-geCGl-paG; expires=Sun, 14-Sep-2014 21:05:42 GMT; path=/; domain=.google.com; HttpOnly | |
P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info." | |
Server: gws | |
X-XSS-Protection: 1; mode=block | |
X-Frame-Options: SAMEORIGIN | |
Alternate-Protocol: 80:quic | |
Transfer-Encoding: chunked | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment