Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I/O, redirection and pipes #20

Closed
ccronje opened this issue Dec 8, 2016 · 12 comments
Closed

I/O, redirection and pipes #20

ccronje opened this issue Dec 8, 2016 · 12 comments
Assignees

Comments

@ccronje
Copy link
Contributor

ccronje commented Dec 8, 2016

I think we should describe I/O, redirection and pipes before the example $ grep 2009 2014-01_JA.tsv | grep INTERNATIONAL | awk -F'\t' '{print $5}' | sort | uniq -c. It would provide context and reinforce the Unix philosophy of small programs which perform a specific task - building blocks to design the workflow you want.

@drjwbaker
Copy link

Hmm. I was thinking about this yesterday when I taught the shell lesson for the first time in over a year! I use this here because my narrative is: by the end of the session you'll feel comfortable describing what is going on here. I know that SWC avoids "big bang" openings such as this, but I like it as it a) offers a clear use case for the shell b) offers a sense of direction and learning outcomes c) means that - I hope - people are less likely to get disillusioned during the opening bit on pwd, ls, cd et cetera which is pretty dull and uninspiring! (by necessity).

@ccronje
Copy link
Contributor Author

ccronje commented Dec 13, 2016

Well done at DST4L! I agree with your reasons - it does help to see the potential. It's a great example to illustrate the the concept of piping input and output. The memory side of things gets a bit complicated https://brandonwamboldt.ca/how-linux-pipes-work-under-the-hood-1518/

@weaverbel
Copy link

@drjwbaker I agree - I like to give people something 'aspirational' - dread word - to inspire them. It helps if you can show them something that will be amazing. I also demo the name counts from Little Women - the speed with which the shell returns the answer always gets them in ...

@drjwbaker
Copy link

@weaverbel Can you sketch out the Little Women example please (when you get a minute!) so we can work it up as an alternative pathway through the lesson?

@weaverbel
Copy link

sure thing @drjwbaker - it's just a word count thing (using a loop) but it impresses people as it's so fast and people think "I could look for the number of times a politician says X in a speech' and other uses. Just in the absolute thick of prepping for Software Carpentry instructor training which concludes tomorrow afternoon and then I can look at it. I promised it to @ccronje too and am conscious of not having given it to her, but I just have really been smashed getting things done ....

@weaverbel
Copy link

@drjwbaker @ccronje
Found it on an etherpad:

For loop:

for name in "Jo" "Meg" "Amy" "Beth"; do echo $name; grep $name littlew.txt  | wc -w; done

Get the file here: 
    http://www.gutenberg.org/cache/epub/514/pg514.txt and Save As littlew.txt (or you will need to change the filename in your loop)

There would be other ways of doing this - this was just one way. It would need to be reworked if you wanted to redirect output to a file.

@danmichaelo
Copy link
Contributor

danmichaelo commented Feb 13, 2017

While I do think it's important to say some inspiring words about why we're learning to use the shell in the beginning, I'm afraid such a complex example might be anything but scary to many newcomers. They might even think that it's normal having to write such long commands when working in the shell! ("How can I ever remember all of this?")

Also, my experience is that participants completely new to the shell do not necessarily find the first part dull. This depends a lot on the audience of course, but for people with no or almost no experience working with any kind of command line, it can actually be quite cool and powerful just to type in any kind of command and see what happens, without having to be afraid that they destroy their computer or something. Also, it opens up a completely new way of navigating the computer without using Finder/Explorer. And finally, it's not dull when you know that this is preparing you for running all kinds of cool scripts in the future!

(not to say it's not a cool example :))

@drjwbaker
Copy link

Okay. I'm happy to concede this one (I know, for example, that SWC dislikes similar flash bang openings). I guess I'm just keen to keep people onside who are learning cd, mv, ls, et cetera - the bit at the beginning which I'm pretty sure is boring.. - and I wondering why bother, why am I here, what am I going to get out of all this. In the other teaching I do (undergraduate history and art history) we work on the principle that you tell people the learning outcomes at the beginning, you show them where they will be at the end of the course, module, class. The opening example, then, is my attempt to do that for LC. Maybe, instead of a canonical example written into the lesson, the lesson could/should start with a prompt to the instructor to tell the audience something they did with the shell this week/month that was a) simple b) powerful c) achievable with a little learning (I also work on https://datapraxis.github.io/sourcecaster/ where we collect examples of these)

@weaverbel
Copy link

I am with @drjwbaker here. I have just taught a Software Carpentry Python class for Brisbane Resbaz and I think both shell and Python AND Git would have benefited from an initial, early 'this will save you time/make things more efficient/isn't this awesome' moment? If we are going to lead people into the promised land, we need an early sighting of some milk and honey before they start to trudge across the stony desert that is the command line to many ;-) I really think we need to inspire people about where they will end up - doing something quickly and cleverly (and easily) that they couldn't do before.

@drjwbaker
Copy link

So as a compromise does this..

Maybe, instead of a canonical example written into the lesson, the lesson could/should start with a prompt to the instructor to tell the audience something they did with the shell this week/month that was a) simple b) powerful c) achievable with a little learning

..work for you @weaverbel?

@weaverbel
Copy link

Yes, that should be fine @drjwbaker (and I guess there is always leeway for people to do that anyway).

@drjwbaker drjwbaker self-assigned this Feb 20, 2017
@drjwbaker
Copy link

Superseded so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants