Skip to main content
added 291 characters in body
Source Link
Wildcard
  • 37.5k
  • 30
  • 149
  • 284

Sure it's possible.

(Unless you are also concerned about temporary files being potentially created "under the hood," as virtually all text editors work that way. I don't say it is flatly impossible to avoid any possibility under-the-hood temp file creation, but it's not covered in this answer.)

printf '%s\n' '0r file1' x | ex file2

This is a POSIX-compliant command using ex, the POSIX-specified non-visual predecessor to vi.

printf is only used here to feed a command to the editor. What printf outputs is:

0r file1
x

x is save and exit.

r is "read in the contents of the named file."

0 specifies the line number after which the read-in text should be placed.

Sure it's possible.

printf '%s\n' '0r file1' x | ex file2

This is a POSIX-compliant command using ex, the POSIX-specified non-visual predecessor to vi.

printf is only used here to feed a command to the editor. What printf outputs is:

0r file1
x

x is save and exit.

r is "read in the contents of the named file."

0 specifies the line number after which the read-in text should be placed.

Sure it's possible.

(Unless you are also concerned about temporary files being potentially created "under the hood," as virtually all text editors work that way. I don't say it is flatly impossible to avoid any possibility under-the-hood temp file creation, but it's not covered in this answer.)

printf '%s\n' '0r file1' x | ex file2

This is a POSIX-compliant command using ex, the POSIX-specified non-visual predecessor to vi.

printf is only used here to feed a command to the editor. What printf outputs is:

0r file1
x

x is save and exit.

r is "read in the contents of the named file."

0 specifies the line number after which the read-in text should be placed.

Source Link
Wildcard
  • 37.5k
  • 30
  • 149
  • 284

Sure it's possible.

printf '%s\n' '0r file1' x | ex file2

This is a POSIX-compliant command using ex, the POSIX-specified non-visual predecessor to vi.

printf is only used here to feed a command to the editor. What printf outputs is:

0r file1
x

x is save and exit.

r is "read in the contents of the named file."

0 specifies the line number after which the read-in text should be placed.