How To

How to Create a File in Unix

Contributor
By John Wu
eHow Contributing Writer
(0 Ratings)
Create a File in Unix
Create a File in Unix

Creating a file is very easy to do in Unix. Many Unix users make programs that create zero length files on the fly from the command line. In other cases, Unix users need to create files that have results from other files. Even though creating a file in Unix is essential to using Unix productively, the procedure to create a file can be done in one short command depending on what the file should contain.

Difficulty: Easy
Instructions
  1. Step 1

    Log into the Unix system with your user name and password.

  2. Step 2

    Open a command line window. In most Unix GUI environments, click on the icon that looks like a computer terminal.

  3. Step 3

    Type "touch filename" to create a file called "filename." This command creates a zero length file called filename. This method is commonly used to create lock files, where a program will stop running if it detects a lock file exists, which means another instance of the same program is running.
    If the file already exists, this command updates the last modified date and time attribute for the file without changing the contents of the file.

  4. Step 4

    Type "cat /etc/hosts > filename". This command copies the content of the /etc/hosts file into a new file called filename. This is a good way to create a new file with data in it.

Post a Comment

Post a Comment
  • Have you done this? Click here to let us know.
I Did This

Related Ads

Computers
Alexia Petrakos,

Meet Alexia Petrakos eHow's Computers Expert.

Get Free Computers Newsletters

Copyright © 1999-2009 eHow, Inc. Use of this web site constitutes acceptance of the eHow Terms of Use and Privacy Policy.   en-US

eHow Computers
eHow_eHow Technology and Electronics