- C 84.3%
- Shell 13.1%
- Makefile 2.6%
| src | print formatting clean up | |
| tests | test runner script bugs/typos fixed | |
| .gitignore | setup new project | |
| LICENSE | Initial commit | |
| Makefile | shorter flag names & compiler fix in makefile | |
| README.md | expand file type assignment | |
Limited Scope ls (lsls)
NAME
lsls — list directory contents (limited-scope ls util program)
SYNOPSIS
lsls [ -AacdFfhiklnqRrSstuw] [file...]
DESCRIPTION
For each operand that names a file of a type other than directory, lsls displays its name as well as any requested, associated information.
For each operand that names a file of type directory, lsls displays the names of files contained within that directory, as well as any requested, associated information.
If no operands are given, the contents of the current directory are displayed.
If more than one operand is given, non-directory operands are displayed first; directory and non-directory operands are sorted separately and in lexicographical order.
The following options are available:
-A: List all entries except for.and... Always set for the super-user.-a: Include directory entries whose names begin with a dot (.).-c: Use time when file status was last changed, instead of time of last modification of the file for sorting (-t) or printing (-l).-d: Directories are listed as plain files (not searched recursively) and symbolic links in the argument list are not indirected through.-F: Display a slash (/) immediately after each pathname that is a directory, an asterisk (∗) after each that is executable, an at sign (@) after each symbolic link, a percent sign (%) after each whiteout, an equal sign (=) after each socket, and a vertical bar (|) after each that is a FIFO.-f: Output is not sorted.-h: Modifies the -s and -l options, causing the sizes to be reported in bytes displayed in a human readable format. Overrides-k.-i: For each file, print the file’s file serial number (inode number).-k: Modifies the -s option, causing the sizes to be reported in kilobytes. The rightmost of the-kand-hflags overrides the previous flag. See also-h.-l: (The lowercase letter "ell"). List in long format. (See below.)-n: The same as-l, except that the owner and group IDs are displayed numerically rather than converting to a owner or group name.-q: Force printing of non-printable characters in file names as the character?; This is the default when output is to a terminal.-R: Recursively list subdirectories encountered.-r: Reverse the order of the sort to get reverse lexicographical order or the smallest or oldest entries first.-S: Sort by size, largest file first.-s: Display the number of file system blocks actually used by each file, in units of 512 bytes orBLOCKSIZE(see ENVIRONMENT) where partial units are rounded up to the next integer value. If the output is to a terminal, a total sum for all the file sizes is output on a line before the listing.-t: Sort by time modified (most recently modified first) before sorting the operands by lexicographical order.-u: Use time of last access, instead of last modification of the file for sorting (-t) or printing (-l).-w: Force raw printing of non-printable characters. This is the default when output is not to a terminal.
The -w, and -q options override each other; the last one specified determines the format used for non-print-able characters.
The -l and -n options override each other, the last one specified determines the format used.
The -c and -u options override each other; the last one specified determines the file time used.
By default, lsls lists one entry per line to standard output.
File information is displayed with one or more (blank) separating the information associated with the -i, -s, and -l options.
The Long Format
If the -l option is given, the following information is displayed for each file:
- file mode
- number of links
- owner name
- group name
- number of bytes in the file
- abbreviated month file was last modified
- day-of-month file was last modified
- hour and minute file was last modified
- pathname
In addition, for each directory whose contents are displayed, the total number of blocks in units of 512 bytes or BLOCKSIZE (see ENVIRONMENT) used by the files in the directory is displayed on a line by itself immediately before the information for the files in the directory.
If the owner or group names are not a known owner or group name, or the -n option is given, the numeric ID’s are displayed.
If the file is a character special or block special file, the major and minor device numbers for the file are displayed in the size field.
If the file is a symbolic link the pathname of the linked-to file is preceded by ->.
The file mode printed under the -l option consists of the entry type, owner permissions, group permissions, and other permissions.
The entry type character describes the type of file, as follows:
bBlock special file.cCharacter special file.dDirectory.lSymbolic link.sSocket link.pFIFO.-Regular file.
The next three fields are three characters each: owner permissions, group permissions, and other permissions. Each field has three character positions:
- If
r, the file is readable; if-, it is not readable. - If
w, the file is writable; if-, it is not writable. - The first of the following that applies:
SIf in the owner permissions, the file is not executable and set-user-ID mode is set. If in the group permissions, the file is not executable and set-group-ID mode is set.sIf in the owner permissions, the file is executable and set-user-ID mode is set. If in the group permissions, the file is executable and setgroup-ID mode is set.xThe file is executable or the directory is searchable.-The file is neither readable, writable, executable, nor set-user-ID nor set-group-ID mode, nor sticky. (See below.) These next two apply only to the third character in the last group (other permissions).TThe sticky bit is set (mode 1000), but not execute or search permission. (See chmod(1) or sticky(7).)tThe sticky bit is set (mode 1000), and is searchable or executable. (See chmod(1) or sticky(7).)
The number of bytes displayed for a directory is a function of the number of dirent(5) structures in the directory, not all of which may be allocated to any existing file.
ENVIRONMENT
The following environment variables affect the execution of lsls:
BLOCKSIZE: If the environment variableBLOCKSIZEis set, and the-hand-koptions are not specified, the block counts (see-s) will be displayed in units of that size block.TZ: The timezone to use when displaying dates. See environ(7) for more information.
EXIT STATUS
The lsls utility exits zero(0) on success, and greater than zero (>0) if an error occurs.
Credits and Aknowledgemnts:
The source of this project idea was taken from the "Advanced Programming in the UNIX Environment - CS631 Course - Midterm Project. A few of the files in this repo, specifically those listed hereinafter, were pulled from the above public course webpage:
All subsequent additions/removals/modifications made to those files or any others in this repo are my own work.
This project is made available under the Creative Commons Attribution 4.0 International License.