November 8th & 9th, 2024
Love SeaGL and want to help out? Get Involved

Beginning Shell Scripting with Bash

SeaGL 2013

Bash is a shell with a command-line interface for invoking other programs on the Linux system. It is a also a powerful programming language for controlling complex job flows using pipelines and conditional/looping constructs. Combined with the GNU coreutils programs and perhaps a few simple filter programs written in Perl or Python, complex programs can be composed in just a few lines.

This session will provide a live demo showing how fairly complex systems can be built from the available primitive operations. For example, to count down the top ten words (Letterman-style) occurring in a file, say mydata.txt, you may type this command line:

cat mydata.txt | sed -r -e 's/[^A-Za-z]+/\ /g' | sed -e '/^$/d' | sort | uniq -c | sort -n -r | head -10 | cat -n | tac

Looks complex and possibly even slightly intimidating at first, but we’ll build it up piece by piece. Save it in a script file, top-ten-words.sh that you can reuse.

Presenters

Morris Bernstein

Morris Bernstein

Resources