Online Book Reader

Home Category

Classic Shell Scripting - Arnold Robbins [247]

By Root 976 0
a way to direct output from one process into two or more unrelated processes. They generalize ordinary pipes, which have only one writer and one reader.

The GNU stat command from the coreutils package displays the results of the stat( ) system call, which returns inode information about the file. Here is an example of its use with the file from SGI IRIX that we used earlier:

$ stat /bin/true

Report inode information about the file

File: `/bin/true'

Size: 312 Blocks: 8 IO Block: 65536 regular file

Device: eeh/238d Inode: 380 Links: 1

Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ sys)

Access: 2003-12-09 09:02:56.572619600 -0700

Modify: 1999-11-04 12:07:38.887783200 -0700

Change: 1999-11-04 12:07:38.888253600 -0700

The information shown more compactly by ls is just a subset of stat's more detailed report.

GNU stat supports fancy format sequences that allow you to select any subset of the data in the full report. For example, a software installation package could use them to find out whether the filesystem has sufficient free space to proceed. Consult the stat manual pages for details.

Only a few Unix flavors (FreeBSD, GNU/Linux, NetBSD, and SGI IRIX) supply a native stat command. Here are three more samples of their diverse output:

$ /usr/bin/stat /usr/bin/true

FreeBSD 5.0 (one long output line, wrapped here to fit)

1027 1366263 -r-xr-xr-x 1 root wheel 5464488 3120 "Dec 2 18:48:36 2003"

"Jan 16 13:29:56 2003" "Apr 4 09:14:03 2003" 16384 8 /usr/bin/true

$ stat -t /bin/true

GNU/Linux terse inode information

/bin/true 312 8 81ed 0 0 ee 380 1 0 0 1070985776 941742458 941742458 65536

$ /sbin/stat /bin/true

SGI IRIX system utility

/bin/true:

inode 380; dev 238; links 1; size 312

regular; mode is rwxr-xr-x; uid 0 (root); gid 0 (sys)

projid 0 st_fstype: xfs

change time - Thu Nov 4 12:07:38 1999 <941742458>

access time - Tue Dec 9 09:02:56 2003 <1070985776>

modify time - Thu Nov 4 12:07:38 1999 <941742458>

* * *

[20] Just in case octal (base-8) and binary (base-2) number systems are unfamiliar to you, octal notation with digits 0-7 is simply a convenient way of writing the binary values 0002, 0012, 0102, 0112, 1002, 1012, 1102, and 1112. Think of an automobile odometer with only two digits on each wheel, instead of ten.

[21] BSD systems are an exception: they provide the sappnd and uappnd flags, settable with chflags.

[22] epoch, ep'ok, n. A fixed point of time from which succeeding years are numbered [The New Webster Encyclopedic Dictionary of the English Language].

[23] In the interests of committee harmony, UTC is a language-independent acronym; the French expansion is Temps Universel Coordonné. See http://www.npl.co.uk/time/time_scales.html, http://aa.usno.navy.mil/faq/docs/UT.html, and http://www.boulder.nist.gov/timefreq/general/misc.htm for some interesting history of time standards.

[24] Set the variable backup-by-copying-when-linked to non-nil, and the variable backup-by-copying to nil, to preserve hard links. See the section Copying versus Renaming in the emacs manual.

[25] And they in turn got that limit from computer punched cards, which were invented by Hermann Hollerith in the 1880s to help process the 1890 U.S. Census data. His company eventually become IBM. See Geoffrey D. Austrian, Herman Hollerith—Forgotten Giant of Information Processing, Columbia University Press, 1982, ISBN 0-231-05146-8, and Thomas J. Watson Jr. and Peter Petre, Father Son & Co.—My Life at IBM and Beyond, Bantam Books, 1990, ISBN 0-553-07011-8, for interesting stories of the early days of computing.

Unix File Ownership and Privacy Issues

We have made numerous mentions of file permissions, showing how they control read, write, and execute access to files and directories. By careful choice of file permissions, you can, and should, control who can access your files.

The most important tool for access control is the umask command, since it limits the permissions assigned to all files that you subsequently create. Normally, you pick a default value and set it in the file that

Return Main Page Previous Page Next Page

®Online Book Reader