LinuxCommandLibrary

st.2

Get file status

TLDR

Print count, min, max, sum, mean, and standard deviation for numbers in a file

$ st [path/to/file]
copy

Print statistics from stdin
$ cat [path/to/file] | st
copy

Print only the sum of the numbers
$ st [[-s|--sum]] [path/to/file]
copy

Print only the mean of the numbers
$ st [[-m|--mean]] [path/to/file]
copy

Print only the standard deviation
$ st [[-s|--sd]] [path/to/file]
copy

Transpose output (keys in one column, values in another)
$ st [[-t|--transpose]] [path/to/file]
copy

SYNOPSIS

stat [OPTION]... FILE...

PARAMETERS

-L, --dereference
    Follow symbolic links. If FILE is a symbolic link, stat will display information about the file the link points to, rather than the link itself.

-f, --file-system
    Display file system status instead of file status. This shows information about the file system where FILE resides, such as block size, total blocks, free blocks, and available inodes.

-c, --format=FORMAT
    Use the specified FORMAT instead of the default output format. FORMAT can contain C-style backslash escapes and percentage sequences to print specific file or file system information.

-t, --terse
    Print the information in a terse (simplified) form. This option is mostly for backward compatibility.

--help
    Display a help message and exit.

--version
    Output version information and exit.

DESCRIPTION


Important Note: The command "st.2" is not a standard Linux command or system call. The ".2" suffix typically refers to section 2 of the Unix/Linux manual pages, which describes system calls (e.g., stat(2)). It is possible that "st.2" is a typo or a specific reference to an unlisted or custom tool.

This analysis assumes "st.2" was intended to refer to the standard Linux command stat(1), which is used to display detailed information (status) about files or file systems. The stat command retrieves metadata such as file size, access and modification times, permissions, owner, group, and inode number without displaying the file's content. It is a fundamental utility for inspecting file system objects and is part of the GNU Core Utilities.

CAVEATS

As stated in the description, "st.2" is not a standard, executable Linux command. This analysis is provided for stat(1), which is the most probable intended command when considering "st" in the context of system utilities that provide "status" information. The ".2" in "st.2" typically refers to the system call interface (e.g., stat(2) is the system call that stat(1) uses). Another less likely interpretation for "st" could be the "simple terminal" (st), a minimalist terminal emulator, but this is an application rather than a command-line utility for status checks.

OUTPUT FORMAT SPECIFIERS

The --format option is powerful for custom output. Common specifiers for files include:
%n: File name
%s: Total size in bytes
%F: File type
%a: Access permissions in octal
%A: Access permissions in human-readable form
%U: User name of owner
%G: Group name of owner
%x: Time of last access
%y: Time of last modification
%z: Time of last status change
For file systems (with -f):
%T: Type of file system
%b: Total data blocks on file system
%f: Free blocks available to non-privileged user
%i: Total inodes
%c: Free inodes available to non-privileged user

EXIT STATUS

The stat command exits with a status of 0 if successful, and a non-zero value if an error occurred (e.g., file not found, permission denied).

HISTORY

The functionality of the stat command is deeply rooted in the Unix operating system. It relies on the stat(2) system call, which has been a fundamental part of Unix since its early versions (e.g., AT&T System V, BSD). The user-level stat(1) command, typically found in GNU Core Utilities on Linux systems, provides a convenient interface to this system call. Over time, options like --format have been added to provide highly customizable output, making it an invaluable tool for scripting and detailed system analysis.

SEE ALSO

ls(1), df(1), du(1), find(1), readlink(1), stat(2)

Copied to clipboard