How to save a file in Unix using command line

To save a file in Unix using the command line, you can use the vi editor. Here’s how:

  1. Open the vi editor:
$ vi filename

Replace filename with the name of the file you want to create.

  1. Press the i key to enter insert mode.
  2. Type or paste the content of the file.
  3. Press the Esc key to exit insert mode.
  4. Type :w and press Enter to save the file.
  5. Type :q and press Enter to quit the vi editor.

Alternatively, you can use the nano editor, which is easier to use for beginners. To use nano, simply run the following command:

$ nano filename

Replace filename with the name of the file you want to create. The nano editor has a user-friendly interface that displays commands at the bottom of the screen. To save the file, press Ctrl + O and then press Ctrl + X to exit the editor.

Leave a Comment