1

In GNU ed, how do I move to a line without printing it? If I want to move to line 123, I would input 123 Enter, but that would also print the contents of the line. Is there a way to not print when moving to a line?

Flux
  • 2,938

1 Answers1

3

Most of the time, you either want to move to a line and print it (which is the default action if no other command is given), or move to a line and perform some other command. It's a bit unusual to want to move to a line without continuing with some command... There is no "no-op" command in standard ed.

GNU ed introduces a non-standard command called #, which does nothing.

This means you could use the command 1;# to move to the first line and then invoke the no-op command #. You can't use 1# as # does not take any address. An address that looks like n; (for some line number n) is interpreted as "first go to line n" so that 4;/foo/ would mean the first line after line 4 that contains foo. Compare that with 4,/foo/ which is a range of several lines from line 4 to the first line matching /foo/ relative to the current line.

Summary: The command sequence 123;# moves to line 123 and then does nothing in GNU ed.

Kusalananda
  • 333,661