About us Privacy Disclaimer Contact us
FAQ Help Advertising Feedback
Home Sitemap Search Donate us

  Home > Computer & I'net > Files - 3...

   Browse by title articles:
   What is hot:

Files - 3

Files - 4

Forms & Hashes
Perl Basics
Why Re-Design
A Way for Search Engines to Improve
Prev articles12345 6 



Files - 3


Computer & I'net articlesFiles - 3

by David Stanley    



This page will show a few different things you can do with files.

The rename command changes the name of an existing file. It also moves that file if you specify a different path.
rename ("existing_name.ext", "new_name.ext");

The unlink command deletes a file or list of files from the system. Be sure you want to do this. It permanently removes the files.
unlink ("filename.ext");

The chmod command controls the same chmod properties as you would do using your FTP program. It assigns or changes the chmod properties of a specified file.
chmod (mode, "filename.ext");
The mode is a zero, then the three numbers discussed on the CHMOD page.
Example :
chmod (0755, "example.txt");

In some cases, you may want to find the status of a file. These tools are sometimes referred to as the -x file tests because of the format you invoke them in. These tests are used along with a file handle to find a result.
letter... Determines if given is...
-b a block device
-c a character device
-d a directory
-e existing
-f an ordinary file
-g has a setgid
-k has a sticky bit set
-l a symbolic link
-o owned by a current user
-p a named pipe
-r readable
-s contains any information
-t represents a terminal
-u has a setuid
-w writable
-x exectuable
-z empty
-A how long it has been since the given was last accessed
-B a binary file
-C how long it has been since a file's inode has been accessed
-M how long it has been since the given was modified.
-O owned by the current user. The current user's ID is set at the time of login.
-R readable by the current user.
-S a socket.
-T a text file.
-W writable by the current user
-X executable by the current user.

Example :
# check to see if file exists
if (-e "output.txt"){
    print "The file actually exists! ";
    } else {
    print "That file does not exist in the current directory ";
    }



-----------------

Article by David Stanley. Visit his site http://www.htmlite.com. Reprinted with permission.






Articles

Auto & Trucks

Business

Computer & I'net

  ·General

  ·Apache

  ·CSS

  ·Database

  ·Hardware

  ·HTML

  ·Javascript&DHTML

  ·Linux

  ·MySQL

  ·Operating System

Perl / CGI

  ·PHP

  ·Programming

  ·Publishing

  ·Search Engines

  ·Software Problems

  ·SSI

  ·Tips & Tricks

  ·Utilities

  ·Web Design

Family

Food & Drink

Gardening

Health

Other

Pets

Psychology

Spiritual

Travel

Women

 Calculators

Group Work




  Disclaimer | Privacy | Terms of useCopyright © 2004 Nice2know.com