SED: Pattern Matching Across More than 1 Line
Yes, this is something that a lot of people want to do (whether they realise it or not) as the s/pattern1/replacement/ does not work if the string spans more than one line. Example Suppose we want to replace every instance of Microsoft Windows 95 with Linux (I mean, just replace the text !). Our first attempt is this: s/Microsoft Windows 95/Linux/g Unfortunately, the script fails if our file looks like this: Microsoft Windows 95 Since neither line matches the pattern microsoft Windows 95 So we need to do better. We need the "multiline next" or N command. The next command […]
Read more