file - Manipulate file names and attributes
file option name ?arg arg ...?
This command provides several operations on a file's name or attributes.
Name is the name of a file; if it starts with a tilde, then tilde
substitution is done before executing the command (see the manual entry for
filename for details). Option indicates what to do with the
file name. Any unique abbreviation for option is acceptable. The
valid options are:
- file atime name
-
file copy ?-force? ?--? source target
file copy ?-force? ?--? source ?source ...? targetDir
The first form makes a copy of the file or directory source under
the pathname target. If target is an existing directory,
then the second form is used. The second form makes a copy inside
targetDir of each source file listed. If a directory is
specified as a source, then the contents of the directory will be
recursively copied into targetDir. Existing files will not be
overwritten unless the -force option is specified. Trying to
overwrite a non-empty directory, overwrite a directory with a file, or a
file with a directory will all result in errors even if -force was
specified. Arguments are processed in the order specified, halting at the
first error, if any. A -- marks the end of switches; the argument
following the -- will be treated as a source even if it
starts with a -.
- file delete ?-force? ?--? pathname ?pathname ... ?
-
- file dirname name
-
Returns a name comprised of all of the path components in name
excluding the last element. If name is a relative file name and
only contains one path element, then returns ``.'' (or ``:''
on the Macintosh). If name refers to a root directory, then the
root directory is returned. For example,
file dirname c:/
returns c:/.
Note that tilde substitution will only be
performed if it is necessary to complete the command. For example,
file dirname ~/src/foo.c
returns ~/src, whereas
file dirname ~
returns /home (or something similar).
- file executable name
-
- file exists name
-
- file extension name
-
- file isdirectory name
-
- file isfile name
-
- file join name ?name ...?
-
file join a b /foo bar
returns /foo/bar.
Note that any of the names can contain separators, and that the result
is always canonical for the current platform: / for Unix and
Windows, and : for Macintosh.
- file lstat name varName
-
- file mkdir dir ?dir ...?
-
- file mtime name
-
- file owned name
-
- file pathtype name
-
- file readable name
-
- file readlink name
-
file rename ?-force? ?--? source target
file rename ?-force? ?--? source ?source ...? targetDir
The first form takes the file or directory specified by pathname
source and renames it to target, moving the file if the
pathname target specifies a name in a different directory. If
target is an existing directory, then the second form is used. The
second form moves each source file or directory into the directory
targetDir. Existing files will not be overwritten unless the
-force option is specified. Trying to overwrite a non-empty
directory, overwrite a directory with a file, or a file with a directory
will all result in errors. Arguments are processed in the order specified,
halting at the first error, if any. A -- marks the end of
switches; the argument following the -- will be treated as a
source even if it starts with a -.
- file rootname name
-
- file size name
-
- file split name
-
file split /foo/~bar/baz
returns / foo ./~bar baz to ensure that later commands
that use the third component do not attempt to perform tilde
substitution.
- file stat name varName
-
- file tail name
-
- file type name
-
- file writable name
-
- Unix
-
filename
attributes, copy files, delete files, directory, file, move files, name, rename files, stat
Copyright © 1993 The Regents of the University of California.
Copyright © 1994-1996 Sun Microsystems, Inc.
Copyright © 1995, 1996 Roger E. Critchlow Jr.