Friday, February 1, 2013

Shell Scripting != Java

Last semester, my Java professor told us that once you learn the basic concepts and patterns of one programming language, it is fairly easy to learn other languages.  I found that to be true when I started playing with Python, PHP, and now Processing.... but Shell scripting totally threw me for a loop.  I have never worked in an environment using a low level language, and I didn't realize what the differences would be.  Our first Shell class was similar to my first Java class.  We went over lots of basic commands and how to use them.  Our assignment was to write a script that would echo information from some of the commands we learned.  We were supposed to figure out on our own how to use echo and specifically, how to echo special characters.  I looked in the unix manual to find out how to echo the special characters, and this is what the manual says:


Ummm, ok.  Nothing about special characters.  Nothing about correct syntax or any examples of ways to use it.  What's an alert?  How would it even be possible to echo a backspace?  I remember being slightly lost with Java's API the first time I looked at it:


But at least it uses complete sentences in the explanations and has links to the info pages on related commands. After searching Google and listening to last week's lecture I realized that echo is println.  :) Duh.  Once I realized that, everything we were doing made so much more sense!! 

This week's lab we are going over conditionals and loops.  I am comfortable with these concepts, but it is still very different from Java.  


This is what I got started in class.  The first line of the program just drives me crazy.  For name in *... Ugh.  Not declaring variables seems so unorganized.  And what an awkward place to create a variable. I feel like I am telling the computer, "For as many, (name of a variable that you have no idea what it is yet), in all of this directory..."   And there is no =, which seems necessary for an assignment statement.  I think Shell is kind of like the teenage girl of programming languages.  "I already know everything, don't talk to me, and good luck trying to figure me out because my user manual sucks."  

That's my current feelings on learning Shell, we will see how I feel about it next month. Now I'm off to finish this lab....  I'm trying to figure out how to tell it to add the word counts together, when there is all that extra text in the output.  I wish I had a parseInt.  :)  
   




No comments:

Post a Comment