Learning Bash

Over the years I’ve written a lot of batch files in MS-DOS and whatever they call the current command line interface in Windows these days. I guess I’ve gained a bit of proficiency with it. In a former job I created a number of batch scripts to automate configuration of the computers I was deploying as well as utility scripts. Now that I’m using Linux more, it makes sense for me to write scripts in that environment too.

The catalyst to learn more about Bash scripts was to streamline a little task I wanted to do on my system. For years I’ve been keeping a journal in html format and I save interesting images to a folder for inclusion in my journal. In my file browser, I like to view the directory by modification date in reverse order so that the most recent files are a the beginning.

Occasionally, I find some images that I’d like to keep near the beginning of the directory listing for easy retrieval. I’d open a terminal window and manually touch each file individually but that became a tedious process after a while and the idea of writing a script for it made sense.

I entered the appropriate file names into a text file and wrote a simple script to use a while loop to read the file names from the list and run the touch command against them. That worked pretty well. Then, as I delved more into some tutorials I found ways to make my script more robust and reusable. Instead of a hard-coded target filename, I set it up to take a command line argument and then as it read the list, test to make sure the file existed, just in case I’d forgotten to remove I filename I no longer needed.

Out of the plethora of Bash tutorials out there on the Internet, I found a couple targeted toward a beginner but even they seem to presume intimacy with Linux commands so when I attempt some of the suggested exercises, I find myself searching for information on commands or ways to accomplish tasks. Quite often I find the information a little above my current level of geek fluency. There is so much that I’ve forgotten from my days as a Computer Science student.

Maybe I haven’t found the right tutorial yet or I need to find a good Bash for Dummies book. Even a classroom environment might be helpful in that I could ask questions, get immediate feedback, and learn from others.


2 Responses

  1. I worked my way part way through an online tutorial over the weekend and attempted many of the chapter exercises. Most of them required research on commands which was good for learning. And there were several where I had no idea where to even begin. Others I wasn’t sure how to implement the logic of the processes involved.

    For some of the exercises, I developed or found solutions that didn’t require what was covered in the lesson or the commands he suggested.

    In most of those cases I wasn’t able to figure out how to implement the lessons into the solution. It would have been nice if the tutorials author had included an addendum with possible solutions to the exercises to point me in the right direction.

    I’ve also downloaded a few more tutorials/books in pdf format that I’ll be reading.

  2. I’m still working my way through the same online Bash tutorial and I’m starting to feel more comfortable with writing scripts as I get familiar with the structure and syntax. Lack of familiarity with many of the Linux commands is a bit of a drawback but I’m learning as I research them.

    Some of the joy that I used to have for writing code is starting to resurface. That’s a good thing. It was never really dead, just buried.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: