How to: create files in Linux from a bash shell prompt

Source: Internet
Author: User

ByVivek GITEOn October 16,200 7 ·23 comments

Q. I'm new to Linux and installed centos on my laptop. How do I create a file from Bash prompt without using GUI tools?

A.Linux/Unix offer commands line tools and text editors for creating text files. you can use VI or Joe text editor. it is a terminal-based text editor for Linux/Unix systems, available under the GPL. it is designed to be easy to use.

Create a text file using cat command

To create a text file called foo.txt, enter:
$ Cat> foo.txt
Output:

 
This is a test. Hello world! PressCTRL + dTo save file

To display file contents, Type
$ Cat foot.txt

Create a text file using Joe Text Editor

Joe is text editor. To create a file called foo.txt, type:
$ Joe-help foo.txt
You will see help menu on screen. Next type something. To save the file and leave Joe, by typing ^ kx (press Ctrl + K + x ).

Create a text file using vi/Vim Text Editor

VI/Vim is another text editor. To create a file called bar.txt, type:
$ VI bar.txt
Press 'I' to insert new text. To save the file and Leave Vi, type ESC ++: + x (Press ESC key, type: followed by X and [enter] key ).

Further readings
    • Learn more about Joe here: Introduction to the Joe Text Editor
    • Learn more about VI here: Download mastering the VI editor PDF version.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.