Keyboard and screen of a Datapoint 2200 terminal
Photo by KenShirriff from Wikimedia Commons, CC BY-SA 4.0, cropped

Operating Systems

Line Filter with sed

Press Filter.

Lines of the text
No Line State

What is left

How it works

The script of my practice work removes empty lines from a file with the command sed '/^[ ]*$/d': sed reads the text line by line and deletes every line that matches the pattern between the slashes. The pattern ^[ ]*$ matches a line that has nothing but spaces from its beginning ^ to its end $. On this page the pattern is checked by the browser, so it is a JavaScript regular expression; simple patterns work the same way in sed.

From the course

  • Semester 5
  • Practice work 6: a bash script with sed

Useful resources

  1. sed, a stream editor the GNU manual