Changes

Jump to: navigation, search

OPS435 Lecture 9 - Bash

909 bytes added, 22:02, 30 March 2016
Created page with 'Today we've done a couple of walkthroughs, and started regular expressions. There will be lots of walkthroughs on the exam! Here are the ones we did in class: walk1.sh: <sourc…'
Today we've done a couple of walkthroughs, and started regular expressions. There will be lots of walkthroughs on the exam!

Here are the ones we did in class:

walk1.sh:

<source lang="bash">#!/bin/bash

echo -n " Stuff: "
i=5
for ((i=10; i < 20; i++))
{
echo -n $i
}
echo .
</source>

walk2.sh:

<source lang="bash">
#!/bin/bash

cat passwd | while read ABC
do
N=`echo $ABC | cut -d: -f1`
S=`echo $ABC | cut -d: -f7`
echo "$N -> $S"
done

echo '$N -> $S'
</source>

For regular expressions we looked at egrep for searching, specifically the following special characters:

* ^ $ . *

And sed for search+replace. Sed is an important topic in this course, all that you need to learn about it is in the first few sections of [http://www.grymoire.com/Unix/Sed.html this tutorial]. By the end of the course you have to be comfortable at least with everything up to and including the "/p print" section.

Navigation menu