To save a file in Unix using the command line, you can use the vi editor. Here’s how:
- Open the
vieditor:
$ vi filename
Replace filename with the name of the file you want to create.
- Press the
ikey to enter insert mode. - Type or paste the content of the file.
- Press the
Esckey to exit insert mode. - Type
:wand pressEnterto save the file. - Type
:qand pressEnterto quit thevieditor.
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.