Sed Assignment

As you did for the grep assignment, create a script(name this one assign8) to display the appropriate Unix sed command and the result of the command for each of the following: (use the words dictionary).

Place the script assign8 and the output of the script (assign8.out) in your OBSDIAN drop box.

Note: Use only sed commands.

  1. Use sed to replace first occurence of "za" on the line with "jj". Only display the changed lines. Pipe your result through head
  2. For any lines that contain "quin", replace all "t"s on the line with a "v". Display only changed lines. Pipe your result through head
  3. For all lines that start with an "u" and end with a vowel (any case), find the pattern "at" and remove everything after the "at". Show only changed lines. Pipe your result through head.
  4. Find all the words that start with a vowel (lower case) and end with "ch"; substitute the first "a" with an "x". Show only the changed words. Pipe through head.
  5. In the first 60 lines of the words file, substitute all the "a"s with "x"s. Show all modified lines.
  6. In the first 60 lines of the words file, substitute the second "A" on the line with a "Z". Only show the changed lines.

    For the following, use the ALREADY created file named textfile that has the contents of the Guardian Newspaper below starting with the title.
  7. Replace all occurences of "will" and all that follows will on the line with "WILL WIN." adding a '.' at the end. Show only changed lines
  8. delete lines 4 through 8 (so, 1 to 3 and lines after 8 are displayed)
  9. delete lines 9 through the end (regardless of the number of lines)
  10. display the lines from the line that contains "butchered" through the line containing "bullets"


By Guardian Newspapers, 4/6/2003

It was another tough day in front of the
cameras for Mohammed Saeed al-Sahaf.
But if the Iraqi minister of information
was feeling the strain now that the war
has reached Baghdad, he certainly wasn't showing it.

Neat as ever in his rimless spectacles, green Ba'ath party uniform and black beret, the man who is Saddam Hussein's mouthpiece continued to spin loyally for his elusive master yesterday.

"This aggression will end in failure," he said, warning
Baghdadis to beware of rumours and lies. "After its destruction,
Iraq will remain and it will be led by President Saddam Hussein.
This regime will not be destroyed by mercenaries."

Enemy troops, Mr Sahaf insisted to the now familiar forest of microphones at his noon press conference in the city's Palestine Hotel, had been hit by Iraqi missiles in the battle around Saddam International airport.

"We butchered the force present at the airport," he announced. But he did not mention any Iraqi casualties.

... His mixture of bombast, exaggerations and lies raises intriguing questions about how much ordinary Iraqis know about what is happening at this fateful moment. Late last week he was still scoffing at reports that US forces were at the gates of Baghdad.

"They have no foothold in Iraq," he told reporters. "We will welcome them with bullets and shoes." Being hit with a shoe is a grave insult in the Arab world.