To save a file in Unix using the command line, you can use the vi
editor. Here’s how:
- Open the
vi
editor:
$ vi filename
Replace filename
with the name of the file you want to create.
- Press the
i
key to enter insert mode. - Type or paste the content of the file.
- Press the
Esc
key to exit insert mode. - Type
:w
and pressEnter
to save the file. - Type
:q
and pressEnter
to quit thevi
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.