SED Starter Homework

Write what these SED commands will produce when run over the file sedtester. Then run the command and explain why the result was different. Then upload the word document to moodle in the SED Starter Task.

Create a  sedtester that contains:

The cat born

11/12/2012 guards the top of the stairs. The dog born 10/14/2013

 is scared to cross that cat. That cat is funny.

--

Instructions

Just use sed to see the output without actually changing the file (so do not use the -i option). Do use -r to get the extended regex processing.

sed  -r 'list of editing commands' filename

list of editing commands is similar to what you can use in VI in command mode.

Remember that the substitution command can use a regular expression

---

Write what these will produce when run over the file sedtester. Then run the command and explain why the result was different.

Simple sed using VI commands:

1.1. sed 2d sedtester __________________________________________________

1.2. sed = sedtester _________________________________________

1.3. sed iabc sedtester_________________________________________

1.4. sed 2iinsertedLine sedtester_________________________________________

1.5. sed 2cnewstuff sedtester ________________________________________

1.6 sed  -n 1,2p sedtester ________________________________________

1.7 sed -n /cat/p sedtester ________________________________________

1.9 sed /cat/d sedtester ________________________________________

1.10 sed –r '/cat/!d' sedtester ________________________________________

Sed   simple substitution (the s for substitution is the same as the s for substitution for vi that you have been using)

2.4 sed s/cat/goat/ sedtester ________________________________________

2.4 sed s/cat/goat/g sedtester ________________________________________

2.3 sed 2,3s/cat/goat/g sedtester ________________________________________

SED regex

3.1 sed  's/^/Start of line /' sedtester ________________________________________

Note that the single quotes are required

3.2 sed   's/^is/IS/g'   sedtester ________________________________________