StevensNet.com

...Because someone's gotta tell the story...

Blogs

To return to the main Blog List, click Full Blog Listing.

Tags

Site Updates
Technical

Linux Tricks: Creating Files

Tuesday, October 09, 2018 in Linux (Views: 308)
Just a series of short little blogs on how to do things in Linux...

To create files, there is a touch command. You can also use echo to achieve the same goal.

Method 1: Touch
simply type touch and the file name. For example:
touch newfile
This will create a file called newfile, 0 bytes.

Starting in a new directory and running the touch command:
[breakglass@learn a]$ ls
[breakglass@learn a]$ touch newfile
[breakglass@learn a]$ ls
newfile


Doing a cat will show it empty:
[breakglass@learn a]$ cat newfile
[breakglass@learn a]$


Method 2: Echo
You can echo into a new file and it will perform the same result of creating a new file, but we will add text to the file.
[breakglass@learn a]$ ls
[breakglass@learn a]$ echo "This is a new file" > newfile
[breakglass@learn a]$ ls
newfile
[breakglass@learn a]$ cat newfile
This is a new file


2 fast ways to create new files.

 

Related Blogs You May Be Interested In:


To leave a comment, please log in and/or register.