Wednesday, January 7, 2015

How to create file on Lubuntu

In this article i will show you how to create a file on lubuntu/ubuntu, and this tutorial is for beginners, so you don't have to read it if you already know.

Alright to create a file on lubuntu is very simple, you just use touch command it will create an empty file for you.

touch [filename]

touch README.txt

You can create any kind of file you want, like txt, html, php, css, json, xml, even jpg, bmp, pdf, etc. But ideally you should create only text based file.

touch index.htm
touch index.php
touch style.css
touch data.xml
touch image.jpg

Once the file is created, you can edit the content using text editor like vi, vim, gedit, etc. Here's an example :
  1. touch test.php
  2. vim test.php
  3. inside vim, press insert (or i) and then type the content you want
  4. after done inserting content, press escape button (Esc)
  5. and then exit with :wq
Another way to create an empty file is using the > sign, and to fill the content we can use >> sign. Here's an example :

  1. > diary.txt
  2. echo this is my diary >> diary.txt
  3. echo i love working with lubuntu >> diary.txt
  4. cat diary.txt

No comments:

Post a Comment