Showing posts with label regular expressions. Show all posts
Showing posts with label regular expressions. Show all posts

Thursday, January 10, 2013

Blog Series: WoG, Cesky Krumlov; Day 3: Unix, Part 2--Ninja-ery

Julian Catchen
University of Oregon
Unix Ninja

Topic: Unix Part 2

So unfortunately as with the quality control blog, I am or will be unable to give you files that we practiced on but Julian's slides are quite good. We learned about pipes and added on to our current knowledge of command line. We finished up the end of the first slide set... which included all the following commands:

  • man [command you are confused about]: manual for commands that gives you all the options. Some man pages are more helpful than others but if you stare at it long enough it'll start to make sense. Often times there are examples of usage so pay attention to those.
  • ls, gunzip, more, cat, head, tail, grep, wc...all that we learned yesterday--so don't forget it and today we ended up having to man some of those commands to learn the options.
  • sort [filename], just as it sounds--depending on what kind of sort you want you have to specify an option (see man page for sort; ie. numeric, alphabetical)
  • uniq [filename], as with sort, lots of options to tease things out of your file.
  • cut [filename], we learned this before too--BUT I learned anew that it is only for column files today.
  • tr "       " "," [filename]: translate command that changes all tabs to commas in the given filename.
  • tab = Ctrl+V+tab or \t
  • |, this is a 'pipe' read Julian's slides part 1
Example: What do you think I just did to this file?

cat batch_1.genotypes_1.loc | tr "    " "," | grep "^96053"

  1. I grabbed the file = cat
  2. I piped it to the command 'tr' specifying I wanted all tabs changed to commas
  3. Then piped it to another command 'grep' (remember what grep does?)
  4. With grep I specified I wanted to look for all entries where the beginning of the line (hat symbol) started with 96053

We didn't get through all these slides but they are great so have a gander...

What we did get through: