uutils Coreutils Documentation
uutils is an attempt at writing universal (as in cross-platform) CLI utilities in Rust. It is available for Linux, Windows, Mac and other platforms.
The API reference for uucore, the library of functions shared between various
utils, is hosted at docs.rs.
uutils is licensed under the MIT License.
Useful links
Note: This manual is automatically generated from the source code and is a work in progress.
Installation
This is a list of uutils packages in various distributions and package managers. Note that these are packaged by third-parties and the packages might contain patches.
You can also build uutils from source.
Cargo
# Unix like
cargo install coreutils --features unix --locked
# Windows
cargo install coreutils --features windows --locked
Linux
Alpine
apk update uutils-coreutils
Note: Requires the
edgerepository.
Arch
pacman -S uutils-coreutils
Debian
apt install rust-coreutils
# To use it:
export PATH=/usr/lib/cargo/bin/coreutils:$PATH
Fedora
dnf install uutils-coreutils
# To use it:
export PATH=/usr/libexec/uutils-coreutils:$PATH
Gentoo
emerge -pv sys-apps/uutils-coreutils
Manjaro
pacman -S uutils-coreutils
# or
pamac install uutils-coreutils
NixOS
nix-env -iA nixos.uutils-coreutils
OpenMandriva Lx
dnf install uutils-coreutils
RHEL/AlmaLinux/CENTOS Stream/Rocky Linux/EPEL 9
# Install EPEL 9 - Specific For RHEL please check codeready-builder-for-rhel-9 First then install epel
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm -y
# Install Core Utils
dnf install uutils-coreutils
# To use it:
export PATH=/usr/libexec/uutils-coreutils:$PATH
Ubuntu
apt install rust-coreutils
# To use it:
export PATH=/usr/lib/cargo/bin/coreutils:$PATH
AUR
Rust rewrite of the GNU coreutils (main branch).
MacOS
Homebrew
brew install uutils-coreutils
MacPorts
port install coreutils-uutils
FreeBSD
pkg install rust-coreutils
Windows
Winget
winget install uutils.coreutils
Scoop
scoop install uutils-coreutils
MSYS2
MSYS2 package (Windows native)
Alternative installers
Conda
conda install -c conda-forge uutils-coreutils
Yocto
The uutils-coreutils recipe is provided as part of the meta-openembedded yocto layer.
Clone poky and meta-openembedded, add
meta-openembedded/meta-oe as layer in your build/conf/bblayers.conf file,
and then either call bitbake uutils-coreutils, or use
PREFERRED_PROVIDER_coreutils = "uutils-coreutils" in your build/conf/local.conf file and
then build your usual yocto image.
Build from source
Requirements
- Rust (
cargo,rustc) - GNU Make (optional)
Rust Version
uutils follows Rust’s release channels and is tested against stable, beta and nightly.
Building
There are currently two methods to build the uutils binaries: either Cargo or GNU Make.
Building the full package, including all documentation, requires both Cargo and GNU Make on a Unix platform.
For either method, we first need to fetch the repository:
git clone https://github.com/uutils/coreutils
cd coreutils
Cargo
Building uutils using Cargo is easy because the process is the same as for every other Rust program:
cargo build --release
Replace --release with --profile=release-small to optimize binary size.
This command builds the most portable common core set of uutils into a multicall (BusyBox-type) binary, named ‘coreutils’, on most Rust-supported platforms.
Additional platform-specific uutils are often available. Building these expanded sets of uutils for a platform (on that platform) is as simple as specifying it as a feature:
cargo build --release --features windows
# or ...
cargo build --release --features unix
To build SELinux-specific features, including chcon and runcon, ensure that libselinux
and libclang are installed on your system. Then, run the following command:
cargo build --release --features unix,feat_selinux
If you don’t want to build every utility available on your platform into the final binary, you can also specify which ones you want to build manually. For example:
cargo build --features "base32 cat echo rm" --no-default-features
If you want to build the utilities as individual binaries, that is also possible:
cargo build --release --bins --workspace --exclude coreutils --exclude uu_runcon --exclude uu_chcon
Each utility is contained in its own package within the main repository, named “uu_UTILNAME”. To
build selected individual utilities, use the --package [aka -p] option. For example:
cargo build -p uu_base32 -p uu_cat -p uu_echo -p uu_rm
GNU Make
Building using make is a simple process as well.
To simply build all available utilities (with debug profile):
make
In release mode:
make PROFILE=release
To build all but a few of the available utilities:
make SKIP_UTILS='UTILITY_1 UTILITY_2'
To build only a few of the available utilities:
make UTILS='UTILITY_1 UTILITY_2'
Installation
Install with Cargo
Likewise, installing can simply be done using:
cargo install --path . --locked
This command will install uutils into Cargo’s bin folder (e.g.
$HOME/.cargo/bin).
This does not install files necessary for shell completion or manpages. For
manpages or shell completion to work, use GNU Make or see
Manually install shell completions/Manually install manpages.
Install with GNU Make
To install all available utilities (PROFILE=release by default):
make install
To install using sudo switch -E must be used:
sudo -E make install
To install all but a few of the available utilities:
make SKIP_UTILS='UTILITY_1 UTILITY_2' install
To install only a few of the available utilities:
make UTILS='UTILITY_1 UTILITY_2' install
To install every program with a prefix (e.g. uu-echo uu-cat):
make PROG_PREFIX=uu- install
To install the multicall binary:
make MULTICALL=y install
Set install parent directory (default value is /usr/local):
# DESTDIR is also supported
make PREFIX=/my/path install
Installing with make installs shell completions for all installed utilities
for bash, fish and zsh. Completions for elvish and powershell can also
be generated; See Manually install shell completions.
To skip installation of completions and manpages:
make COMPLETIONS=n MANPAGES=n install
Manually install shell completions
The uudoc binary generates completions for the bash, elvish,
fish, powershell and zsh shells to stdout.
Install uudoc by
cargo install --bin uudoc --features uudoc --path .
Then use the installed binary:
uudoc completion <utility> <shell>
So, to install completions for ls on bash to
/usr/local/share/bash-completion/completions/ls, run:
uudoc completion ls bash > /usr/local/share/bash-completion/completions/ls.bash
Completion for prefixed cp with uu- on zsh is generated by
env PROG_PREFIX=uu- uudoc completion cp zsh
Manually install manpages
To generate manpages, the syntax is:
uudoc manpage <utility>
So, to install the manpage for ls to /usr/local/share/man/man1/ls.1 run:
uudoc manpage ls > /usr/local/share/man/man1/ls.1
Un-installation
Un-installation differs depending on how you have installed uutils. If you used Cargo to install, use Cargo to uninstall. If you used GNU Make to install, use Make to uninstall.
Uninstall with Cargo
To uninstall uutils:
cargo uninstall coreutils
Uninstall with GNU Make
To uninstall all utilities:
make uninstall
To uninstall every program with a set prefix:
make PROG_PREFIX=uu- uninstall
To uninstall the multicall binary:
make MULTICALL=y uninstall
To uninstall from a custom parent directory:
# DESTDIR is also supported
make PREFIX=/my/path uninstall
Platform support
uutils aims to be as “universal” as possible, meaning that we try to support many platforms. However, it is infeasible for us to guarantee that every platform works. Just like Rust itself, we therefore have multiple tiers of platform support, with different guarantees. We support two tiers of platforms:
- Tier 1: All applicable utils are compiled and tested in CI for these platforms.
- Tier 2: These platforms are supported but not actively tested. We do accept fixes for these platforms.
Note: The tiers are dictated by our CI. We would happily accept a job in the CI for testing more platforms, bumping those platforms to tier 1.
Platforms per tier
The platforms in tier 1 and the platforms that we test in CI are listed below.
| Operating system | Tested targets |
|---|---|
| Linux | x86_64-unknown-linux-gnu x86_64-unknown-linux-musl arm-unknown-linux-gnueabihf i686-unknown-linux-gnu aarch64-unknown-linux-gnu |
| macOS | x86_64-apple-darwin |
| Windows | i686-pc-windows-msvc x86_64-pc-windows-gnu x86_64-pc-windows-msvc |
| FreeBSD | x86_64-unknown-freebsd |
| OpenBSD | x86_64-unknown-openbsd |
| Android | x86_64-linux-android |
| wasm32 | wasm32-wasip1 |
The platforms in tier 2 are more vague, but include:
- untested variations of the platforms above,
- Redox OS,
- and BSDs such as NetBSD & DragonFlyBSD.
Utility compatibility per platform
Not all utils work on every platform. For instance, chgrp is not supported on
Windows, because Windows does not have the concept of groups. Below is a full table
detailing which utilities are supported for the tier 1 platforms.
Note that for some utilities, not all functionality is supported on each platform. This is documented per utility.
| util | Linux | macOS | Windows | FreeBSD | Android |
|---|---|---|---|---|---|
| arch | ✓ | ✓ | ✓ | ✓ | |
| b2sum | ✓ | ✓ | ✓ | ✓ | ✓ |
| base32 | ✓ | ✓ | ✓ | ✓ | |
| base64 | ✓ | ✓ | ✓ | ✓ | |
| basename | ✓ | ✓ | ✓ | ✓ | |
| basenc | ✓ | ✓ | ✓ | ✓ | |
| cat | ✓ | ✓ | ✓ | ✓ | |
| chcon | ✓ | ||||
| chgrp | ✓ | ✓ | ✓ | ||
| chmod | ✓ | ✓ | ✓ | ||
| chown | ✓ | ✓ | ✓ | ||
| chroot | ✓ | ✓ | ✓ | ||
| cksum | ✓ | ✓ | ✓ | ✓ | ✓ |
| comm | ✓ | ✓ | ✓ | ✓ | |
| cp | ✓ | ✓ | ✓ | ✓ | |
| csplit | ✓ | ✓ | ✓ | ✓ | |
| cut | ✓ | ✓ | ✓ | ✓ | |
| date | ✓ | ✓ | ✓ | ✓ | |
| dd | ✓ | ✓ | ✓ | ✓ | |
| df | ✓ | ✓ | ✓ | ✓ | |
| dir | ✓ | ✓ | ✓ | ✓ | |
| dircolors | ✓ | ✓ | ✓ | ✓ | |
| dirname | ✓ | ✓ | ✓ | ✓ | |
| du | ✓ | ✓ | ✓ | ✓ | |
| echo | ✓ | ✓ | ✓ | ✓ | |
| env | ✓ | ✓ | ✓ | ✓ | |
| expand | ✓ | ✓ | ✓ | ✓ | |
| expr | ✓ | ✓ | ✓ | ✓ | |
| factor | ✓ | ✓ | ✓ | ✓ | |
| false | ✓ | ✓ | ✓ | ✓ | |
| fmt | ✓ | ✓ | ✓ | ✓ | |
| fold | ✓ | ✓ | ✓ | ✓ | |
| groups | ✓ | ✓ | ✓ | ||
| head | ✓ | ✓ | ✓ | ✓ | |
| hostid | ✓ | ✓ | |||
| hostname | ✓ | ✓ | ✓ | ✓ | |
| id | ✓ | ✓ | ✓ | ||
| install | ✓ | ✓ | ✓ | ||
| join | ✓ | ✓ | ✓ | ✓ | |
| kill | ✓ | ✓ | ✓ | ||
| link | ✓ | ✓ | ✓ | ✓ | |
| ln | ✓ | ✓ | ✓ | ✓ | |
| logname | ✓ | ✓ | ✓ | ||
| ls | ✓ | ✓ | ✓ | ✓ | |
| md5sum | ✓ | ✓ | ✓ | ✓ | ✓ |
| mkdir | ✓ | ✓ | ✓ | ✓ | |
| mkfifo | ✓ | ✓ | ✓ | ||
| mknod | ✓ | ✓ | ✓ | ||
| mktemp | ✓ | ✓ | ✓ | ✓ | |
| more | ✓ | ✓ | ✓ | ✓ | |
| mv | ✓ | ✓ | ✓ | ✓ | |
| nice | ✓ | ✓ | ✓ | ||
| nl | ✓ | ✓ | ✓ | ✓ | |
| nohup | ✓ | ✓ | ✓ | ||
| nproc | ✓ | ✓ | ✓ | ✓ | |
| numfmt | ✓ | ✓ | ✓ | ✓ | |
| od | ✓ | ✓ | ✓ | ✓ | |
| paste | ✓ | ✓ | ✓ | ✓ | |
| pathchk | ✓ | ✓ | ✓ | ||
| pinky | ✓ | ✓ | |||
| pr | ✓ | ✓ | ✓ | ✓ | |
| printenv | ✓ | ✓ | ✓ | ✓ | |
| printf | ✓ | ✓ | ✓ | ✓ | |
| ptx | ✓ | ✓ | ✓ | ✓ | |
| pwd | ✓ | ✓ | ✓ | ✓ | |
| readlink | ✓ | ✓ | ✓ | ✓ | |
| realpath | ✓ | ✓ | ✓ | ✓ | |
| rm | ✓ | ✓ | ✓ | ✓ | |
| rmdir | ✓ | ✓ | ✓ | ✓ | |
| runcon | ✓ | ||||
| seq | ✓ | ✓ | ✓ | ✓ | |
| sha1sum | ✓ | ✓ | ✓ | ✓ | ✓ |
| sha224sum | ✓ | ✓ | ✓ | ✓ | ✓ |
| sha256sum | ✓ | ✓ | ✓ | ✓ | ✓ |
| sha384sum | ✓ | ✓ | ✓ | ✓ | ✓ |
| sha512sum | ✓ | ✓ | ✓ | ✓ | ✓ |
| shred | ✓ | ✓ | ✓ | ✓ | |
| shuf | ✓ | ✓ | ✓ | ✓ | |
| sleep | ✓ | ✓ | ✓ | ✓ | |
| sort | ✓ | ✓ | ✓ | ✓ | |
| split | ✓ | ✓ | ✓ | ✓ | |
| stat | ✓ | ✓ | ✓ | ||
| stdbuf | ✓ | ✓ | ✓ | ||
| stty | ✓ | ✓ | ✓ | ||
| sum | ✓ | ✓ | ✓ | ✓ | ✓ |
| sync | ✓ | ✓ | ✓ | ✓ | |
| tac | ✓ | ✓ | ✓ | ✓ | |
| tail | ✓ | ✓ | ✓ | ✓ | |
| tee | ✓ | ✓ | ✓ | ✓ | |
| test | ✓ | ✓ | ✓ | ✓ | |
| timeout | ✓ | ✓ | ✓ | ||
| touch | ✓ | ✓ | ✓ | ✓ | |
| tr | ✓ | ✓ | ✓ | ✓ | |
| true | ✓ | ✓ | ✓ | ✓ | |
| truncate | ✓ | ✓ | ✓ | ✓ | |
| tsort | ✓ | ✓ | ✓ | ✓ | |
| tty | ✓ | ✓ | ✓ | ||
| uname | ✓ | ✓ | ✓ | ✓ | |
| unexpand | ✓ | ✓ | ✓ | ✓ | |
| uniq | ✓ | ✓ | ✓ | ✓ | |
| unlink | ✓ | ✓ | ✓ | ✓ | |
| uptime | ✓ | ✓ | |||
| users | ✓ | ✓ | |||
| vdir | ✓ | ✓ | ✓ | ✓ | |
| wc | ✓ | ✓ | ✓ | ✓ | |
| who | ✓ | ✓ | |||
| whoami | ✓ | ✓ | ✓ | ✓ | |
| yes | ✓ | ✓ | ✓ | ✓ |
Contributing to coreutils
Hi! Welcome to uutils/coreutils!
Thanks for wanting to contribute to this project! This document explains everything you need to know to contribute. Before you start make sure to also check out these documents:
- Our community’s CODE_OF_CONDUCT.md.
- DEVELOPMENT.md for setting up your development environment.
Now follows a very important warning:
Warning
uutils is original code and cannot contain any code from GNU or other implementations. This means that we cannot accept any changes based on the GNU source code. To make sure that cannot happen, you cannot link to the GNU source code either. It is however possible to look at other implementations under a BSD or MIT license like Apple’s implementation or OpenBSD.
Finally, feel free to join our Discord!
Getting Oriented
uutils is a big project consisting of many parts. Here are the most important parts for getting started:
src/uu: The code for all utilitiessrc/uucore: Crate containing all the shared code between the utilities.tests/by-util: The tests for all utilities.src/bin/coreutils.rs: Code for the multicall binary.docs: the documentation for the websitetests/uutests/: Crate implementing the various functions to test uutils commands.
Each utility is defined as a separate crate. The structure of each of these crates is as follows:
Cargo.tomlsrc/main.rs: contains only a single macro callsrc/<util name>.rs: the actual code for the utilitylocales/en-US.ftl: the util’s stringslocales/fr-FR.ftl: French translation of the util’s strings
We have separated repositories for crates that we maintain but also publish for use by others:
Design Goals
We have the following goals with our development:
- Compatible: The utilities should be a drop-in replacement for the GNU coreutils.
- Cross-platform: All utilities should run on as many of the supported platforms as possible.
- Reliable: The utilities should never unexpectedly fail.
- Performant: Our utilities should be written in fast idiomatic Rust. We aim to match or exceed the performance of the GNU utilities.
- Well-tested: We should have a lot of tests to be able to guarantee reliability and compatibility.
How to Help
There are several ways to help and writing code is just one of them. Reporting issues and writing documentation are just as important as writing code.
Reporting Issues
We can’t fix bugs we don’t know about, so good issues are super helpful! Here are some tips for writing good issues:
- If you find a bug, make sure it’s still a problem on the
mainbranch. - Search through the existing issues to see whether it has already been reported.
- Make sure to include all relevant information, such as:
- Which version or commit hash of uutils did you check?
- Which version of GNU coreutils are you comparing with?
- What platform are you on?
- Provide a way to reliably reproduce the issue.
- Be as specific as possible!
- Please provide the output with LANG=C, except for locale-related bugs.
Writing Documentation
There’s never enough documentation. If you come across any documentation that could be improved, feel free to submit a PR for it!
Writing Code
If you want to submit a PR, make sure that you’ve discussed the solution with the maintainers beforehand. We want to avoid situations where you put a lot of work into a fix that we can’t merge! If there’s no issue for what you’re trying to fix yet, make one before you start working on the PR.
Generally, we try to follow what GNU is doing in terms of options and behavior.
It is recommended to look at the GNU coreutils manual
(on the web,
or locally using info <utility>). It is more in depth than the man pages and
provides a good description of available features and their implementation
details. But remember, you cannot look at the GNU source code!
Also remember that we can only merge PRs which pass our test suite, follow rustfmt, and do not have any warnings from clippy. See DEVELOPMENT.md for more information. Be sure to also read about our Rust style.
Our Rust Style
We want uutils to be written in idiomatic Rust, so here are some guidelines to follow. Some of these are aspirational, meaning that we don’t do them correctly everywhere in the code. If you find violations of the advice below, feel free to submit a patch!
Don’t panic!
The coreutils should be very reliable. This means that we should never panic!.
Therefore, you should avoid using .unwrap() and panic!. Sometimes the use of
unreachable! can be justified with a comment explaining why that code is
unreachable.
Don’t exit
We want uutils to be embeddable in other programs. This means that no function
in uutils should exit the program. Doing so would also lead to code with more
confusing control flow. Avoid therefore std::process::exit and similar
functions which exit the program early.
unsafe
uutils cannot be entirely safe, because we have to call out to libc and do
syscalls. However, we still want to limit our use of unsafe. We generally only
accept unsafe for FFI, with very few exceptions. Note that performance is very
rarely a valid argument for using unsafe.
If you still need to write code with unsafe, make sure to read the
Rustonomicon and annotate the
calls with // SAFETY: comments explaining why the use of unsafe is sound.
Macros
Macros can be a great tool, but they are also usually hard to understand. They should be used sparingly. Make sure to explore simpler options before you reach for a solution involving macros.
str, OsStr & Path
Rust has many string-like types, and sometimes it’s hard to choose the right
one. It’s tempting to use str (and String) for everything, but that is not
always the right choice for uutils, because we need to support invalid UTF-8,
just like the GNU coreutils. For example, paths on Linux might not be valid
UTF-8! Whenever we are dealing with paths, we should therefore stick with
OsStr and Path. Make sure that you only convert to str/String if you
know that something is always valid UTF-8. If you need more operations on
OsStr, you can use the bstr crate.
Doc-comments
We use rustdoc for our documentation, so it’s best to follow rustdoc’s guidelines. Make sure that your documentation is not just repeating the name of the function, but actually giving more useful information. Rustdoc recommends the following structure:
[short sentence explaining what it is]
[more detailed explanation]
[at least one code example that users can copy/paste to try it]
[even more advanced explanations if necessary]
Other comments
Comments should be written to explain the code, not to describe the code. Try to focus on explaining why the code is the way it is. If you feel like you have to describe the code, that’s usually a sign that you could improve the naming of variables and functions.
If you edit a piece of code, make sure to update any comments that need to change as a result. The only thing worse than having no comments is having outdated comments!
Git Etiquette
To ensure easy collaboration, we have guidelines for using Git and GitHub.
Commits
- Make small and atomic commits.
- Keep a clean history of commits.
- Write informative commit messages.
- Annotate your commit message with the component you’re editing. For example:
cp: do not overwrite on with -ioruucore: add support for FreeBSD. - Do not unnecessarily move items around in the code. This makes the changes much harder to review. If you do need to move things around, do that in a separate commit.
Commit messages
You can read this section in the Git book to learn how to write good commit messages.
In addition, here are a few examples for a summary line when committing to uutils:
- commit for a single utility
nohup: cleanup and refactor
- commit for a utility’s tests
tests/rm: test new feature
Beyond changes to an individual utility or its tests, other summary lines for non-utility modules include:
README: add help
uucore: add new modules
uutils: add new utility
gitignore: add temporary files
PRs
- Make the titles of PRs descriptive.
- This means describing the problem you solve. For example, do not write
Fix #1234, butls: fix version sort order. - You can prefix the title with the utility the PR concerns.
- This means describing the problem you solve. For example, do not write
- Keep PRs small and self-contained. A set of small PRs is much more likely to get merged quickly than one large PR.
- Make sure the CI passes (up to intermittently failing tests).
- You know your code best, that’s why it’s best if you can solve merge conflicts
on your branch yourself.
- It’s up to you whether you want to use
git merge mainorgit rebase main. - Feel free to ask for help with merge conflicts.
- It’s up to you whether you want to use
- You do not need to ping maintainers to request a review immediately after submission. If you do not get a response to your patch within a few days, it is fine to request a review.
- If after a week your patch has still not been reviewed, we recommend that you ping the maintainers on our Discord channel in
#coreutils-chat.
- If after a week your patch has still not been reviewed, we recommend that you ping the maintainers on our Discord channel in
Platforms
We take pride in supporting many operating systems and architectures. Any code
you contribute must at least compile without warnings for all platforms in the
CI. However, you can use #[cfg(...)] attributes to create platform dependent
features.
Tip: For Windows, Microsoft provides some images (VMWare, Hyper-V, VirtualBox and Parallels) for development on their official download page.
Improving the GNU compatibility
Please make sure you have installed GNU utils and prerequisites and can execute commands described in Comparing with GNU section of DEVELOPMENT.md
The Python script ./util/remaining-gnu-error.py shows the list of failing
tests in the CI.
To improve the GNU compatibility, the following process is recommended:
- Identify a test (the smaller, the better) on a program that you understand or
is easy to understand. You can use the
./util/remaining-gnu-error.pyscript to help with this decision. - Build both the GNU and Rust coreutils using:
bash util/build-gnu.sh - Run the test with
bash util/run-gnu-test.sh <your test> - Start to modify
<your test>to understand what is wrong. Examples:- Add
set -vto have the bash verbose mode - Add
echo $?where needed - When the variable
failis used in the test,echo $failto see when the test started to fail - Bump the content of the output (ex:
cat err) - …
- Add
- Or, if the test is simple, extract the relevant information to create a new test case running both GNU & Rust implementation
- Start to modify the Rust implementation to match the expected behavior
- Add a test to make sure that we don’t regress (our test suite is super quick)
Code coverage
To generate code coverage report locally please follow Code coverage report section of DEVELOPMENT.md
Other implementations
The Coreutils have different implementations, with different levels of completions:
However, when reimplementing the tools/options in Rust, don’t read their source codes when they are using reciprocal licenses (ex: GNU GPL, GNU LGPL, etc).
Licensing
uutils is distributed under the terms of the MIT License; see the LICENSE file
for details. This is a permissive license, which allows the software to be used
with few restrictions.
Copyrights in the uutils project are retained by their contributors, and no copyright assignment is required to contribute.
If you wish to add or change dependencies as part of a contribution to the
project, a tool like cargo-license can be used to show their license details.
The following types of license are acceptable:
- MIT License
- Dual- or tri-license with an MIT License option (“Apache-2.0 or MIT” is a popular combination)
- “MIT equivalent” license (2-clause BSD, 3-clause BSD, ISC)
- License less restrictive than the MIT License (CC0 1.0 Universal)
- Apache License version 2.0
Licenses we will not use:
- An ambiguous license, or no license
- Strongly reciprocal licenses (GNU GPL, GNU LGPL)
If you wish to add a reference but it doesn’t meet these requirements, please raise an issue to describe the dependency.
Setting up your local development environment
For contributing rules and best practices please refer to CONTRIBUTING.md
Before you start
For this guide we assume that you already have a GitHub account and have git and your favorite code editor or IDE installed and configured.
Before you start working on coreutils, please follow these steps:
- Fork the coreutils repository to your GitHub account. Tip: See this GitHub guide for more information on this step.
- Clone that fork to your local development environment:
git clone https://github.com/YOUR-GITHUB-ACCOUNT/coreutils
cd coreutils
Tools
You will need the tools mentioned in this section to build and test your code changes locally. This section will explain how to install and configure these tools. We also have an extensive CI that uses these tools and will check your code before it can be merged. The next section Testing will explain how to run those checks locally to avoid waiting for the CI.
As an alternative to host installation of the tools, you can open the project with the provided development container configuration. For more information about development containers, see the Visual Studio Code Dev Containers documentation.
Rust toolchain
If you’re using rustup to install and manage your Rust toolchains, clippy and rustfmt are usually already installed. If you are using one of the alternative methods, please make sure to install them manually. See following sub-sections for their usage: clippy rustfmt.
Tip You might also need to add ‘llvm-tools’ component if you are going to generate code coverage reports locally:
rustup component add llvm-tools-preview
GNU utils and prerequisites
If you are developing on Linux, most likely you already have all/most GNU utilities and prerequisites installed.
To make sure, please check GNU coreutils README-prereq.
You will need these to run uutils against the GNU test suite locally.
For MacOS and Windows platform specific setup please check MacOS GNU utils and Windows GNU utils sections respectfully.
pre-commit hooks
A configuration for pre-commit is provided in the repository. It allows
automatically checking every git commit you make to ensure it compiles, and
passes clippy and rustfmt without warnings.
To use the provided hook:
- Install
pre-commit - Run
pre-commit installwhile in the repository directory
Your git commits will then automatically be checked. If a check fails, an error
message will explain why, and your commit will be canceled. You can then make
the suggested changes, and run git commit ... again.
NOTE: On MacOS the pre-commit hooks are currently broken. There are workarounds involving switching to unstable nightly Rust and components.
clippy
cargo clippy --all-targets --all-features
The msrv key in the clippy configuration file clippy.toml is used to disable
lints pertaining to newer features by specifying the minimum supported Rust
version (MSRV).
rustfmt
cargo fmt --all
cargo-deny
This project uses cargo-deny to detect duplicate dependencies, checks licenses, etc. To run it locally, first install it and then run with:
cargo deny --all-features check all
Markdown linter
We use markdownlint to lint the Markdown files in the repository.
Spell checker
We use cspell as spell checker for all files in the project. If you are using
VS Code, you can install the
code spell checker
extension to enable spell checking within your editor. Otherwise, you can
install cspell separately.
If you want to make the spell checker ignore a word, you can add
#![allow(unused)]
fn main() {
// spell-checker:ignore word_to_ignore
}
at the top of the file.
Testing
This section explains how to run our CI checks locally.
Testing can be done using either Cargo or make.
Testing with Cargo
Just like with building, we follow the standard procedure for testing using Cargo:
cargo test
By default, cargo test only runs the common programs. To run also platform
specific tests, run:
cargo test --features unix
If you would prefer to test a select few utilities:
cargo test --features "chmod mv tail" --no-default-features
If you also want to test the core utilities:
cargo test -p uucore -p coreutils
# or
cargo test --all-features -p uucore
Running the complete test suite might take a while. We use nextest in the CI and you might want to try it out locally. It can speed up the execution time of the whole test run significantly if the cpu has multiple cores.
cargo nextest run --features unix --no-fail-fast
To debug:
rust-gdb --args target/debug/coreutils ls
(gdb) b ls.rs:79
(gdb) run
Testing with GNU Make
To simply test all available utilities:
make test
To test all but a few of the available utilities:
make SKIP_UTILS='UTILITY_1 UTILITY_2' test
To test only a few of the available utilities:
make UTILS='UTILITY_1 UTILITY_2' test
To include tests for unimplemented behavior:
make UTILS='UTILITY_1 UTILITY_2' SPEC=y test
To run tests with nextest just use the nextest target. Note you’ll need to
install nextest first. The nextest target accepts the
same arguments like the default test target, so it’s possible to pass arguments to nextest run
via CARGOFLAGS:
make CARGOFLAGS='--no-fail-fast' UTILS='UTILITY_1 UTILITY_2' nextest
Run Busybox Tests
This testing functionality is only available on *nix operating systems and
requires make.
To run busybox tests for all utilities for which busybox has tests
make busytest
To run busybox tests for a few of the available utilities
make UTILS='UTILITY_1 UTILITY_2' busytest
To pass an argument like “-v” to the busybox test runtime
make UTILS='UTILITY_1 UTILITY_2' RUNTEST_ARGS='-v' busytest
Comparing with GNU
To run uutils against the GNU test suite locally, run the following commands:
bash util/build-gnu.sh
# Build uutils with release optimizations
env PROFILE=release bash util/build-gnu.sh
# Build uutils with SELinux
env SELINUX_ENABLED=1 bash util/build-gnu.sh
bash util/run-gnu-test.sh
# To run a single test:
bash util/run-gnu-test.sh tests/touch/not-owner.sh # for example
# To run several tests:
bash util/run-gnu-test.sh tests/touch/not-owner.sh tests/rm/no-give-up.sh # for example
# If this is a perl (.pl) test, to run in debug:
DEBUG=1 bash util/run-gnu-test.sh tests/misc/sm3sum.pl
Tip: First time you run bash util/build-gnu.sh command, it will provide instructions on how to checkout GNU coreutils repository at the correct release tag. Please follow those instructions and when done, run bash util/build-gnu.sh command again.
You also need to install quilt, a tool used to manage a stack of patches for modifying GNU tests.
On FreeBSD, you need to install packages for GNU coreutils and sed (used in shell scripts instead of system commands):
pkg install coreutils gsed
Code coverage report
Code coverage report can be generated using grcov.
To generate gcov-based coverage report
export CARGO_INCREMENTAL=0
export RUSTFLAGS="-Cinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
export RUSTDOCFLAGS="-Cpanic=abort"
export RUSTUP_TOOLCHAIN="nightly"
cargo build <options...> # e.g., --features feat_os_unix
cargo test <options...> # e.g., --features feat_os_unix test_pathchk
grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing --ignore build.rs --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?\#\[derive\()" -o ./target/debug/coverage/
# open target/debug/coverage/index.html in browser
if changes are not reflected in the report then run cargo clean and run the above commands.
Tips for setting up on Mac
C Compiler and linker
On MacOS you’ll need to install C compiler & linker:
xcode-select --install
MacOS GNU utils
On MacOS you will need to install Homebrew and use it to install the following Homebrew formulas:
brew install \
coreutils \
autoconf \
gettext \
texinfo \
xz \
automake \
gnu-sed \
m4 \
bison \
pre-commit \
findutils
After installing these Homebrew formulas, please make sure to add the following lines to your zsh or bash rc file, i.e. ~/.profile or ~/.zshrc or ~/.bashrc …
(assuming Homebrew is installed at default location /opt/homebrew):
eval "$(/opt/homebrew/bin/brew shellenv)"
export PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH"
export PATH="/opt/homebrew/opt/bison/bin:$PATH"
export PATH="/opt/homebrew/opt/findutils/libexec/gnubin:$PATH"
Last step is to link Homebrew coreutils version of timeout to /usr/local/bin (as admin user):
sudo ln -s /opt/homebrew/bin/timeout /usr/local/bin/timeout
Do not forget to either source updated rc file or restart you terminal session to update environment variables.
Tips for setting up on Windows
MSVC build tools
On Windows you’ll need the MSVC build tools for Visual Studio 2013 or later.
If you are using rustup-init.exe to install Rust toolchain, it will guide you through the process of downloading and installing these prerequisites.
Otherwise please follow this guide.
Windows GNU utils
If you have used Git for Windows to install git on you Windows system you might already have some GNU core utilities installed as part of “GNU Bash” included in Git for Windows package, but it is not a complete package. This article provides instruction on how to add more to it.
Alternatively you can install Cygwin and/or use WSL2 to get access to all GNU core utilities on Windows.
Preparing a new release
- Modify
util/update-version.sh(FROM & TO) and run it - Submit a new PR with these changes and wait for it to be merged
- Tag the new release
git tag -a X.Y.Zandgit push --tags - Once the CI is green, a new release will be automatically created in draft mode. Reuse this release and make sure that assets have been added.
- Write the release notes (it takes time) following previous examples
- Run
util/publish.sh --do-itto publish the new release to crates.io
Contributor Covenant Code of Conduct
Our Pledge
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socioeconomic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
Our Standards
Examples of behavior that contributes to a positive environment for our community include:
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
- Focusing on what is best not just for us as individuals, but for the overall community
Examples of unacceptable behavior include:
- The use of sexualized language or imagery, and sexual attention or advances of any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others’ private information, such as a physical or email address, without their explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting
Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
Scope
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at sylvestre@debian.org. All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
1. Correction
Community Impact: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
Consequence: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
2. Warning
Community Impact: A violation through a single incident or series of actions.
Consequence: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
3. Temporary Ban
Community Impact: A serious violation of community standards, including sustained inappropriate behavior.
Consequence: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
4. Permanent Ban
Community Impact: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
Consequence: A permanent ban from any sort of public interaction within the community.
Attribution
This Code of Conduct is adapted from the Contributor Covenant, version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
Community Impact Guidelines were inspired by Mozilla’s code of conduct enforcement ladder.
For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
GNU Test Coverage
uutils is actively tested against the GNU coreutils test suite. The results below are automatically updated every day.
Coverage per category
Click on the categories to see the names of the tests. Green indicates a passing test, yellow indicates a skipped test and red means that the test either failed or resulted in an error.
Progress over time
Extensions over GNU
Though the main goal of the project is compatibility, uutils supports a few features that are not supported by GNU coreutils. We take care not to introduce features that are incompatible with the GNU coreutils. Below is a list of uutils extensions.
General
GNU coreutils provides two ways to define short options taking an argument:
$ ls -w 80
$ ls -w80
We support a third way:
$ ls -w=80
With GNU coreutils, --help usually prints the help message and --version prints the version.
We also commonly provide short options: -h for help and -V for version.
coreutils
Our coreutils calls utility by coreutils utility-name and has --list to run against busybox test suite.
Our coreutils is called as utility-name if its binary name ends with utility-name to support prefixed names.
Longer name is prioritized e.g. sum with the prefix ck is called as cksum.
env
GNU env allows the empty string to be used as an environment variable name.
This is unsupported by uutils, which will show a warning for any such
assignment.
env has an additional -f/--file flag that can
parse .env files and set variables accordingly. This feature is adopted from dotenv style
packages.
cp
cp can display a progress bar when the -g/--progress flag is set.
mv
mv can display a progress bar when the -g/--progress flag is set.
rm
rm can display a progress bar when the -g/--progress flag is set.
more
We provide a simple implementation of more, which is not part of GNU
coreutils. We do not aim for full compatibility with the more utility from
util-linux. Features from more modern pagers (like less and bat) are
therefore welcomed.
cut
cut can separate fields by whitespace (Space and Tab) with -w flag. This
feature is adopted from FreeBSD.
fmt
fmt has additional flags for prefixes: -P/--skip-prefix, -x/--exact-prefix, and
-X/--exact-skip-prefix. With -m/--preserve-headers, an attempt is made to detect and preserve
mail headers in the input. -q/--quick breaks lines more quickly. And -T/--tab-width defines the
number of spaces representing a tab when determining the line length.
printf
printf uses arbitrary precision decimal numbers to parse and format floating point
numbers. GNU coreutils uses long double, whose actual size may be double precision
64-bit float
(e.g 32-bit arm), extended precision 80-bit float
(x86(-64)), or
quadruple precision 128-bit float (e.g. arm64).
Practically, this means that printing a number with high precision will remain exact:
printf "%.48f\n" 0.1
0.100000000000000000000000000000000000000000000000 << uutils on all platforms
0.100000000000000000001355252715606880542509316001 << GNU coreutils on x86(-64)
0.100000000000000000000000000000000004814824860968 << GNU coreutils on arm64
0.100000000000000005551115123125782702118158340454 << GNU coreutils on armv7 (32-bit)
Hexadecimal floats
For hexadecimal float format (%a), POSIX only states that one hexadecimal number
should be present left of the decimal point (0xh.hhhhp±d [1]), but does not say how
many bits should be included (between 1 and 4). On x86(-64), the first digit always
includes 4 bits, so its value is always between 0x8 and 0xf, while on other
architectures, only 1 bit is included, so the value is always 0x1.
However, the first digit will of course be 0x0 if the number is zero. Also,
rounding numbers may cause the first digit to be 0x1 on x86(-64) (e.g.
0xf.fffffffp-5 rounds to 0x1.00p-1), or 0x2 on other architectures.
We chose to replicate x86-64 behavior on all platforms.
Additionally, the default precision of the hexadecimal float format (%a without
any specifier) is expected to be “sufficient for exact representation of the value” [1].
This is not possible in uutils as we store arbitrary precision numbers that may be
periodic in hexadecimal form (0.1 = 0xc.ccc...p-7), so we revert
to the number of digits that would be required to exactly print an
extended precision 80-bit float,
emulating GNU coreutils behavior on x86(-64). An 80-bit float has 64 bits in its
integer and fractional part, so 16 hexadecimal digits are printed in total (1 digit
before the decimal point, 15 after).
Practically, this means that the default hexadecimal floating point output is identical to x86(-64) GNU coreutils:
printf "%a\n" 0.1
0xc.ccccccccccccccdp-7 << uutils on all platforms
0xc.ccccccccccccccdp-7 << GNU coreutils on x86-64
0x1.999999999999999999999999999ap-4 << GNU coreutils on arm64
0x1.999999999999ap-4 << GNU coreutils on armv7 (32-bit)
We can print an arbitrary number of digits if a larger precision is requested,
and the leading digit will still be in the 0x8-0xf range:
printf "%.32a\n" 0.1
0xc.cccccccccccccccccccccccccccccccdp-7 << uutils on all platforms
0xc.ccccccccccccccd00000000000000000p-7 << GNU coreutils on x86-64
0x1.999999999999999999999999999a0000p-4 << GNU coreutils on arm64
0x1.999999999999a0000000000000000000p-4 << GNU coreutils on armv7 (32-bit)
Note: The architecture-specific behavior on non-x86(-64) platforms may change in the future.
seq
Unlike GNU coreutils, seq always uses arbitrary precision decimal numbers, no
matter the parameters (integers, decimal numbers, positive or negative increments,
format specified, etc.), so its output will be more correct than GNU coreutils for
some inputs (e.g. small fractional increments where GNU coreutils uses long double).
The only limitation is that the position of the decimal point is stored in a i64,
so values smaller than 10**(-263) will underflow to 0, and some values larger
than 10(2**63) may overflow to infinity.
See also comments under printf for formatting precision and differences.
seq provides -t/--terminator to set the terminator character.
sort
When sorting with -g/--general-numeric-sort, arbitrary precision decimal numbers
are parsed and compared, unlike GNU coreutils that uses platform-specific long
double floating point numbers.
Extremely large or small values can still overflow or underflow to infinity or zero,
see note in seq.
ls
GNU ls provides two ways to use a long listing format: -l and --format=long. We support a
third way: --long.
GNU ls --sort=VALUE only supports special non-default sort orders.
We support --sort=name, which makes it possible to override an earlier value.
du
du allows birth and creation as values for the --time argument to show the creation time. It
also provides a -v/--verbose flag.
id
id has three additional flags:
-Pdisplays the id as a password file entry-pmakes the output human-readable-Adisplays the process audit user ID
uptime
Similar to the proc-ps implementation and unlike GNU/Coreutils, uptime provides:
-s/--sinceto show since when the system is up-p/--prettyto display uptime in a pretty-printed format
base32/base64/basenc
Just like on macOS, base32/base64/basenc provides -D to decode data.
unexpand
GNU unexpand provides --first-only to convert only leading sequences of blanks. We support a
second way: -f like busybox.
With -U/--no-utf8, you can interpret input files as 8-bit ASCII rather than UTF-8.
expand
expand also offers the -U/--no-utf8 option to interpret input files as 8-bit ASCII instead of UTF-8.
install
install offers FreeBSD’s -U unprivileged option to not change the owner, the group, or the file flags of the destination.
Multi-call binary
uutils includes a multi-call binary from which the utils can be invoked. This reduces the binary size of the binary and can be useful for portability.
The first argument of the multi-call binary is the util to run, after which the regular arguments to the util can be passed.
coreutils [util] [util options]
The --help flag will print a list of available utils.
Example
coreutils ls -l
arch
arch
Display machine architecture
Options
Determine architecture name for current machine.
Examples
View documentation for the original command:
tldr uname
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
b2sum
b2sum [OPTIONS] [FILE]...
Print or check the BLAKE2b checksums
Options
--binary,-b--check,-c-
ck-common-help-check
--warn,-w-
ck-common-help-warn
--status-
ck-common-help-status
--quiet-
ck-common-help-quiet
--ignore-missing-
ck-common-help-ignore-missing
--strict-
ck-common-help-strict
--length,-l-
ck-common-help-length
--tag-
ck-common-help-tag
--text,-t-
ck-common-help-text
--zero,-z-
ck-common-help-zero
Examples
Calculate the BLAKE2 checksum for one or more files:
b2sum {{path/to/file1 path/to/file2 ...}}
Calculate and save the list of BLAKE2 checksums to a file:
b2sum {{path/to/file1 path/to/file2 ...}} > {{path/to/file}}.b2
Calculate a BLAKE2 checksum from stdin:
{{command}} | b2sum
Read a file of BLAKE2 checksums and filenames and verify all files have matching checksums:
b2sum {{[-c|--check]}} {{path/to/file}}.b2
Only show a message for missing files or when verification fails:
b2sum {{[-c|--check]}} --quiet {{path/to/file}}.b2
Only show a message when verification fails, ignoring missing files:
b2sum --ignore-missing {{[-c|--check]}} --quiet {{path/to/file}}.b2
Check a known BLAKE2 checksum of a file:
echo {{known_blake2_checksum_of_the_file}} {{path/to/file}} | b2sum {{[-c|--check]}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
base32
base32 [OPTION]... [FILE]
encode/decode data and print to standard output With no FILE, or when FILE is -, read standard input.
The data are encoded as described for the base32 alphabet in RFC 4648. When decoding, the input may contain newlines in addition to the bytes of the formal base32 alphabet. Use –ignore-garbage to attempt to recover from any other non-alphabet bytes in the encoded stream.
Options
--decode,-d,-D-
base-common-help-decode
--ignore-garbage,-i-
base-common-help-ignore-garbage
--wrap=<COLS>,-w <COLS>-
base-common-help-wrap
Examples
Encode a file:
base32 {{path/to/file}}
Wrap encoded output at a specific width (0 disables wrapping):
base32 {{[-w|--wrap]}} {{0|76|...}} {{path/to/file}}
Decode a file:
base32 {{[-d|--decode]}} {{path/to/file}}
Encode from stdin:
{{command}} | base32
Decode from stdin:
{{command}} | base32 {{[-d|--decode]}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
base64
base64 [OPTION]... [FILE]
encode/decode data and print to standard output With no FILE, or when FILE is -, read standard input.
The data are encoded as described for the base64 alphabet in RFC 3548. When decoding, the input may contain newlines in addition to the bytes of the formal base64 alphabet. Use –ignore-garbage to attempt to recover from any other non-alphabet bytes in the encoded stream.
Options
--decode,-d,-D-
base-common-help-decode
--ignore-garbage,-i-
base-common-help-ignore-garbage
--wrap=<COLS>,-w <COLS>-
base-common-help-wrap
Examples
Encode a file:
base64 {{path/to/file}}
Wrap encoded output at a specific width (0 disables wrapping):
base64 {{[-w|--wrap]}} {{0|76|...}} {{path/to/file}}
Decode a file:
base64 {{[-d|--decode]}} {{path/to/file}}
Encode from stdin:
{{command}} | base64
Decode from stdin:
{{command}} | base64 {{[-d|--decode]}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
basename
basename [-z] NAME [SUFFIX]
basename OPTION... NAME...
Print NAME with any leading directory components removed If specified, also remove a trailing SUFFIX
Options
--multiple,-a-
support multiple arguments and treat each as a NAME
--suffix=<SUFFIX>,-s <SUFFIX>-
remove a trailing SUFFIX; implies -a
--zero,-z-
end each output line with NUL, not newline
Examples
Show only the file name from a path:
basename {{path/to/file}}
Show only the rightmost directory name from a path:
basename {{path/to/directory}}
Show only the file name from a path, with a suffix removed:
basename {{path/to/file}} {{suffix}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
basenc
basenc [OPTION]... [FILE]
Encode/decode data and print to standard output With no FILE, or when FILE is -, read standard input.
When decoding, the input may contain newlines in addition to the bytes of the formal alphabet. Use –ignore-garbage to attempt to recover from any other non-alphabet bytes in the encoded stream.
Options
--decode,-d,-D-
base-common-help-decode
--ignore-garbage,-i-
base-common-help-ignore-garbage
--wrap=<COLS>,-w <COLS>-
base-common-help-wrap
--base64-
same as ‘base64’ program
--base64url-
file- and url-safe base64
--base32-
same as ‘base32’ program
--base32hex-
extended hex alphabet base32
--base16-
hex encoding
--base2lsbf-
bit string with least significant bit (lsb) first
--base2msbf-
bit string with most significant bit (msb) first
--z85-
ascii85-like encoding;
when encoding, input length must be a multiple of 4;
when decoding, input length must be a multiple of 5 --base58-
visually unambiguous base58 encoding
Examples
Encode a file with base64 encoding:
basenc --base64 {{path/to/file}}
Decode a file with base64 encoding:
basenc {{[-d|--decode]}} --base64 {{path/to/file}}
Encode from stdin with base32 encoding with 42 columns:
{{command}} | basenc --base32 {{[-w|--wrap]}} 42
Encode from stdin with base32 encoding:
{{command}} | basenc --base32
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
cat
cat [OPTION]... [FILE]...
Concatenate FILE(s), or standard input, to standard output With no FILE, or when FILE is -, read standard input.
Options
--show-all,-A-
equivalent to -vET
--number-nonblank,-b-
number nonempty output lines, overrides -n
-e-
equivalent to -vE
--show-ends,-E-
display $ at end of each line
--number,-n-
number all output lines
--squeeze-blank,-s-
suppress repeated empty output lines
-t-
equivalent to -vT
--show-tabs,-T-
display TAB characters at ^I
--show-nonprinting,-v-
use ^ and M- notation, except for LF (\n) and TAB (\t)
-u-
(ignored)
Examples
Print the contents of a file to stdout:
cat {{path/to/file}}
Concatenate several files into an output file:
cat {{path/to/file1 path/to/file2 ...}} > {{path/to/output_file}}
Append several files to an output file:
cat {{path/to/file1 path/to/file2 ...}} >> {{path/to/output_file}}
Copy the contents of a file into an output file without buffering:
cat -u {{/dev/tty12}} > {{/dev/tty13}}
Write stdin to a file:
cat - > {{path/to/file}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
chcon
chcon [OPTION]... CONTEXT FILE...
chcon [OPTION]... [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE...
chcon [OPTION]... --reference=RFILE FILE...
Change the SELinux security context of each FILE to CONTEXT. With –reference, change the security context of each FILE to that of RFILE.
Options
--dereference-
Affect the referent of each symbolic link (this is the default), rather than the symbolic link itself.
--no-dereference,-h-
Affect symbolic links instead of any referenced file.
--help-
help
--preserve-root-
Fail to operate recursively on ‘/’.
--no-preserve-root-
Do not treat ‘/’ specially (the default).
--reference=<RFILE>-
Use security context of RFILE, rather than specifying a CONTEXT value.
--user=<USER>,-u <USER>-
Set user USER in the target security context.
--role=<ROLE>,-r <ROLE>-
Set role ROLE in the target security context.
--type=<TYPE>,-t <TYPE>-
Set type TYPE in the target security context.
--range=<RANGE>,-l <RANGE>-
Set range RANGE in the target security context.
--recursive,-R-
Operate on files and directories recursively.
-H-
If a command line argument is a symbolic link to a directory, traverse it. Only valid when -R is specified.
-L-
Traverse every symbolic link to a directory encountered. Only valid when -R is specified.
-P-
Do not traverse any symbolic links (default). Only valid when -R is specified.
--verbose,-v-
Output a diagnostic for every file processed.
Examples
View security context of a file:
ls {{[-lZ|-l --context]}} {{path/to/file}}
Change the security context of a target file, using a reference file:
chcon --reference {{reference_file}} {{target_file}}
Change the full SELinux security context of a file:
chcon {{user}}:{{role}}:{{type}}:{{range/level}} {{filename}}
Change only the user part of SELinux security context:
chcon {{[-u|--user]}} {{user}} {{filename}}
Change only the role part of SELinux security context:
chcon {{[-r|--role]}} {{role}} {{filename}}
Change only the type part of SELinux security context:
chcon {{[-t|--type]}} {{type}} {{filename}}
Change only the range/level part of SELinux security context:
chcon {{[-l|--range]}} {{range/level}} {{filename}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
chgrp
chgrp [OPTION]... GROUP FILE...
chgrp [OPTION]... --reference=RFILE FILE...
Change the group of each FILE to GROUP.
Options
--help-
Print help information.
--changes,-c-
like verbose but report only when a change is made
--silent,-f--quiet-
suppress most error messages
--verbose,-v-
output a diagnostic for every file processed
--preserve-root-
fail to operate recursively on ‘/’
--no-preserve-root-
do not treat ‘/’ specially (the default)
--reference=<RFILE>-
use RFILE’s group rather than specifying GROUP values
--from=<GROUP>-
change the group only if its current group matches GROUP
--recursive,-R-
operate on files and directories recursively
-H-
if a command line argument is a symbolic link to a directory, traverse it
-L-
traverse every symbolic link to a directory encountered
-P-
do not traverse any symbolic links (default)
--dereference-
affect the referent of each symbolic link (this is the default), rather than the symbolic link itself
--no-dereference,-h-
affect symbolic links instead of any referenced file (useful only on systems that can change the ownership of a symlink)
Examples
Change the owner group of a file/directory:
chgrp {{group}} {{path/to/file_or_directory}}
Recursively change the owner group of a directory and its contents:
chgrp {{[-R|--recursive]}} {{group}} {{path/to/directory}}
Change the owner group of a symbolic link:
chgrp {{[-h|--no-dereference]}} {{group}} {{path/to/symlink}}
Change the owner group of a file/directory to match a reference file:
chgrp --reference {{path/to/reference_file}} {{path/to/file_or_directory}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
chmod
chmod [OPTION]... MODE[,MODE]... FILE...
chmod [OPTION]... OCTAL-MODE FILE...
chmod [OPTION]... --reference=RFILE FILE...
Change the mode of each FILE to MODE. With –reference, change the mode of each FILE to that of RFILE.
Options
--help-
Print help information.
--changes,-c-
like verbose but report only when a change is made
--quiet,--silent,-f-
suppress most error messages
--verbose,-v-
output a diagnostic for every file processed
--no-preserve-root-
do not treat ‘/’ specially (the default)
--preserve-root-
fail to operate recursively on ‘/’
--recursive,-R-
change files and directories recursively
--reference-
use RFILE’s mode instead of MODE values
-H-
if a command line argument is a symbolic link to a directory, traverse it
-L-
traverse every symbolic link to a directory encountered
-P-
do not traverse any symbolic links (default)
--dereference-
affect the referent of each symbolic link (this is the default), rather than the symbolic link itself
--no-dereference,-h-
affect symbolic links instead of any referenced file (useful only on systems that can change the ownership of a symlink)
Each MODE is of the form [ugoa]*(-+=)+|[-+=]?[0-7]+.
Examples
Give the [u]ser who owns a file the right to e[x]ecute it:
chmod u+x {{path/to/file}}
Give the [u]ser rights to [r]ead and [w]rite to a file/directory:
chmod u+rw {{path/to/file_or_directory}}
Remove e[x]ecutable rights from the [g]roup:
chmod g-x {{path/to/file}}
Give [a]ll users rights to [r]ead and e[x]ecute:
chmod a+rx {{path/to/file}}
Give [o]thers (not in the file owner’s group) the same rights as the [g]roup:
chmod o=g {{path/to/file}}
Remove all rights from [o]thers:
chmod o= {{path/to/file}}
Change permissions recursively giving [g]roup and [o]thers the ability to [w]rite:
chmod {{[-R|--recursive]}} g+w,o+w {{path/to/directory}}
Recursively give [a]ll users [r]ead permissions to files. Also give e[X]ecute permissions to files that have at least one execution permission and to all sub-directories:
chmod {{[-R|--recursive]}} a+rX {{path/to/directory}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
chown
chown [OPTION]... [OWNER][:[GROUP]] FILE...
chown [OPTION]... --reference=RFILE FILE...
Change file owner and group
Options
--help-
Print help information.
--changes,-c-
like verbose but report only when a change is made
--from=<CURRENT_OWNER:CURRENT_GROUP>-
change the owner and/or group of each file only if its
current owner and/or group match those specified here.
Either may be omitted, in which case a match is not required
for the omitted attribute --preserve-root-
fail to operate recursively on ‘/’
--no-preserve-root-
do not treat ‘/’ specially (the default)
--quiet-
suppress most error messages
--recursive,-R-
operate on files and directories recursively
--reference=<RFILE>-
use RFILE’s owner and group rather than specifying OWNER:GROUP values
--silent,-f--verbose,-v-
output a diagnostic for every file processed
-H-
if a command line argument is a symbolic link to a directory, traverse it
-L-
traverse every symbolic link to a directory encountered
-P-
do not traverse any symbolic links (default)
--dereference-
affect the referent of each symbolic link (this is the default), rather than the symbolic link itself
--no-dereference,-h-
affect symbolic links instead of any referenced file (useful only on systems that can change the ownership of a symlink)
Examples
Change the owner user of a file/directory:
sudo chown {{user}} {{path/to/file_or_directory}}
Change the owner user and group of a file/directory:
sudo chown {{user}}:{{group}} {{path/to/file_or_directory}}
Change the owner user and group to both have the name user:
sudo chown {{user}}: {{path/to/file_or_directory}}
Change the group of a file to a group that the current user belongs to:
chown :{{group}} {{path/to/file_or_directory}}
Recursively change the owner of a directory and its contents:
sudo chown {{[-R|--recursive]}} {{user}} {{path/to/directory}}
Change the owner of a symbolic link:
sudo chown {{[-h|--no-dereference]}} {{user}} {{path/to/symlink}}
Change the owner of a file/directory to match a reference file:
sudo chown --reference {{path/to/reference_file}} {{path/to/file_or_directory}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
chroot
chroot [OPTION]... NEWROOT [COMMAND [ARG]...]
Run COMMAND with root directory set to NEWROOT.
Options
--groups=<GROUP1,GROUP2...>-
Comma-separated list of groups to switch to
--userspec=<USER:GROUP>-
Colon-separated user and group to switch to.
--skip-chdir-
Use this option to not change the working directory to / after changing the root directory to newroot, i.e., inside the chroot.
Examples
Run $SHELL in the new root directory:
sudo chroot {{path/to/new_root}}
Run command as new root directory:
sudo chroot {{path/to/new_root}} {{command}}
Use a specific user and group:
sudo chroot --userspec {{username_or_id}}:{{group_name_or_id}} {{path/to/new_root}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
cksum
cksum [OPTIONS] [FILE]...
Print CRC and size for each file
Options
--algorithm=<ALGORITHM>,-a <ALGORITHM>-
ck-common-help-algorithm
--untagged-
ck-common-help-untagged
--tag-
ck-common-help-tag-default
--length,-l-
ck-common-help-length
--raw-
ck-common-help-raw
--check,-c-
ck-common-help-check
--warn,-w-
ck-common-help-warn
--status-
ck-common-help-status
--quiet-
ck-common-help-quiet
--ignore-missing-
ck-common-help-ignore-missing
--strict-
ck-common-help-strict
--base64-
ck-common-help-base64
--text,-t--binary,-b--zero,-z-
ck-common-help-zero
--debug-
ck-common-help-debug
DIGEST determines the digest algorithm and default output format:
- sysv: (equivalent to sum -s)
- bsd: (equivalent to sum -r)
- crc: (equivalent to cksum)
- crc32b: (only available through cksum)
- md5: (equivalent to md5sum)
- sha1: (equivalent to sha1sum)
- sha2: (equivalent to sha{224,256,384,512}sum)
- sha3: (only available through cksum)
- blake2b: (equivalent to b2sum)
- sm3: (only available through cksum)
Examples
Display a 32-bit checksum, size in bytes and filename:
cksum {{path/to/file}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
comm
comm [OPTION]... FILE1 FILE2
Compare two sorted files line by line.
When FILE1 or FILE2 (not both) is -, read standard input.
With no options, produce three-column output. Column one contains lines unique to FILE1, column two contains lines unique to FILE2, and column three contains lines common to both files.
Options
-1-
suppress column 1 (lines unique to FILE1)
-2-
suppress column 2 (lines unique to FILE2)
-3-
suppress column 3 (lines that appear in both files)
--output-delimiter=<STR>-
separate columns with STR
--zero-terminated,-z-
line delimiter is NUL, not newline
--total-
output a summary
--check-order-
check that the input is correctly sorted, even if all input lines are pairable
--nocheck-order-
do not check that the input is correctly sorted
Examples
Produce three tab-separated columns: lines only in first file, lines only in second file, and common lines:
comm {{file1}} {{file2}}
Print only lines common to both files:
comm -12 {{file1}} {{file2}}
Print only lines common to both files, reading one file from stdin:
cat {{file1}} | comm -12 - {{file2}}
Get lines only found in first file, saving the result to a third file:
comm -23 {{file1}} {{file2}} > {{file1_only}}
Print lines only found in second file, when the files aren’t sorted:
comm -13 <(sort {{file1}}) <(sort {{file2}})
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
cp
cp [OPTION]... [-T] SOURCE DEST
cp [OPTION]... SOURCE... DIRECTORY
cp [OPTION]... -t DIRECTORY SOURCE...
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.
Options
--target-directory=<target-directory>,-t <target-directory>-
copy all SOURCE arguments into target-directory
--no-target-directory,-T-
Treat DEST as a regular file and not a directory
--interactive,-i-
ask before overwriting files
--link,-l-
hard-link files instead of copying
--no-clobber,-n-
don’t overwrite a file that already exists
--recursive,-R,-r-
copy directories recursively
--strip-trailing-slashes-
remove any trailing slashes from each SOURCE argument
--debug-
explain how a file is copied. Implies -v
--verbose,-v-
explicitly state what is being done
--symbolic-link,-s-
make symbolic links instead of copying
--force,-f-
if an existing destination file cannot be opened, remove it and try again (this option is ignored when the -n option is also used). Currently not implemented for Windows.
--remove-destination-
remove each existing destination file before attempting to open it (contrast with –force). On Windows, currently only works for writeable files.
--backup=<CONTROL>-
make a backup of each existing destination file
-b-
like –backup but does not accept an argument
--suffix=<SUFFIX>,-S <SUFFIX>-
override the usual backup suffix
--update-
move only when the SOURCE file is newer than the destination file or when the destination file is missing
-u-
like –update but does not accept an argument
--reflink=<WHEN>-
control clone/CoW copies. See below
--attributes-only-
Don’t copy the file data, just the attributes
--preserve=<ATTR_LIST>-
Preserve the specified attributes (default: mode, ownership (unix only), timestamps), if possible additional attributes: context, links, xattr, all
--preserve-default-attributes,-p-
same as –preserve=mode,ownership(unix only),timestamps
--no-preserve=<ATTR_LIST>-
don’t preserve the specified attributes
--parents-
use full source file name under DIRECTORY
--no-dereference,-P-
never follow symbolic links in SOURCE
--dereference,-L-
always follow symbolic links in SOURCE
-H-
follow command-line symbolic links in SOURCE
--archive,-a-
Same as -dR –preserve=all
-d-
same as –no-dereference –preserve=links
--one-file-system,-x-
stay on this file system
--sparse=<WHEN>-
control creation of sparse files. See below
-Z-
set SELinux security context of destination file to default type
--context=<CTX>-
like -Z, or if CTX is specified then set the SELinux or SMACK security context to CTX
--progress,-g-
Display a progress bar. Note: this feature is not supported by GNU coreutils.
--copy-contents-
NotImplemented: copy contents of special files when recursive
Do not copy a non-directory that has an existing destination with the same or newer modification timestamp; instead, silently skip the file without failing. If timestamps are being preserved, the comparison is to the source timestamp truncated to the resolutions of the destination file system and of the system calls used to update timestamps; this avoids duplicate work if several cp -pu commands are executed with the same source and destination. This option is ignored if the -n or –no-clobber option is also specified. Also, if –preserve=links is also specified (like with cp -au for example), that will take precedence; consequently, depending on the order that files are processed from the source, newer files in the destination may be replaced, to mirror hard links in the source. which gives more control over which existing files in the destination are replaced, and its value can be one of the following:
- all This is the default operation when an –update option is not specified, and results in all existing files in the destination being replaced.
- none This is similar to the –no-clobber option, in that no files in the destination are replaced, but also skipping a file does not induce a failure.
- older This is the default operation when –update is specified, and results in files being replaced if they’re older than the corresponding source file.
Examples
Copy a file to another location:
cp {{path/to/source_file}} {{path/to/target_file}}
Copy a file into another directory, keeping the filename:
cp {{path/to/source_file}} {{path/to/target_parent_directory}}
Recursively copy a directory’s contents to another location (if the destination exists, the directory is copied inside it):
cp {{[-r|--recursive]}} {{path/to/source_directory}} {{path/to/target_directory}}
Copy a directory recursively, in verbose mode (shows files as they are copied):
cp {{[-vr|--verbose --recursive]}} {{path/to/source_directory}} {{path/to/target_directory}}
Copy multiple files at once to a directory:
cp {{[-t|--target-directory]}} {{path/to/destination_directory}} {{path/to/file1 path/to/file2 ...}}
Copy all files with a specific extension to another location, in interactive mode (prompts user before overwriting):
cp {{[-i|--interactive]}} {{*.ext}} {{path/to/target_directory}}
Follow symbolic links before copying:
cp {{[-L|--dereference]}} {{link}} {{path/to/target_directory}}
Use the full path of source files, creating any missing intermediate directories when copying:
cp --parents {{source/path/to/file}} {{path/to/target_file}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
csplit
csplit [OPTION]... FILE PATTERN...
Split a file into sections determined by context lines
Options
--suffix-format=<FORMAT>,-b <FORMAT>-
use sprintf FORMAT instead of %02d
--prefix=<PREFIX>,-f <PREFIX>-
use PREFIX instead of ‘xx’
--keep-files,-k-
do not remove output files on errors
--suppress-matched-
suppress the lines matching PATTERN
--digits=<DIGITS>,-n <DIGITS>-
use specified number of digits instead of 2
--quiet,--silent,-q,-s-
do not print counts of output file sizes
--elide-empty-files,-z-
remove empty output files
Output pieces of FILE separated by PATTERN(s) to files ‘xx00’, ‘xx01’, …, and output byte counts of each piece to standard output.
Examples
Split a file in two parts, starting the second one at line 10:
csplit {{path/to/file}} 10
Split a file in three parts, starting the latter parts in lines 7 and 23:
csplit {{path/to/file}} 7 23
Start a new part at every 5th line (will fail if number of lines is not divisible by 5):
csplit {{path/to/file}} 5 {*}
Start a new part at every 5th line, ignoring exact-division error:
csplit {{[-k|--keep-files]}} {{path/to/file}} 5 {*}
Split a file above line 5 and use a custom prefix for the output files (default is xx):
csplit {{path/to/file}} 5 {{[-f|--prefix]}} {{prefix}}
Split a file above the first line matching a regex pattern:
csplit {{path/to/file}} /{{regex}}/
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
cut
cut OPTION... [FILE]...
Prints specified byte or field columns from each line of stdin or the input files
Options
--bytes=<LIST>,-b <LIST>-
filter byte columns from the input source
--characters=<LIST>,-c <LIST>-
alias for character mode
--delimiter=<DELIM>,-d <DELIM>-
specify the delimiter character that separates fields in the input source. Defaults to Tab.
-w <WHITESPACE>-
Use any number of whitespace (Space, Tab) to separate fields in the input source (FreeBSD extension).
--fields=<LIST>,-f <LIST>-
filter field columns from the input source
--complement-
invert the filter - instead of displaying only the filtered columns, display all but those columns
--only-delimited,-s-
in field mode, only print lines which contain the delimiter
--zero-terminated,-z-
instead of filtering columns based on line, filter columns based on \0 (NULL character)
--output-delimiter=<NEW_DELIM>-
in field mode, replace the delimiter in output lines with this option’s argument
-n-
(ignored)
Each call must specify a mode (what to use for columns), a sequence (which columns to print), and provide a data source
Specifying a mode
Use –bytes (-b) or –characters (-c) to specify byte mode
Use –fields (-f) to specify field mode, where each line is broken into fields identified by a delimiter character. For example for a typical CSV you could use this in combination with setting comma as the delimiter
Specifying a sequence
A sequence is a group of 1 or more numbers or inclusive ranges separated by a commas.
cut -f 2,5-7 some_file.txt
will display the 2nd, 5th, 6th, and 7th field for each source line
Ranges can extend to the end of the row by excluding the second number
cut -f 3- some_file.txt
will display the 3rd field and all fields after for each source line
The first number of a range can be excluded, and this is effectively the same as using 1 as the first number: it causes the range to begin at the first column. Ranges can also display a single column
cut -f 1,3-5 some_file.txt
will display the 1st, 3rd, 4th, and 5th field for each source line
The –complement option, when used, inverts the effect of the sequence
cut –complement -f 4-6 some_file.txt
will display the every field but the 4th, 5th, and 6th
Specifying a data source
If no sourcefile arguments are specified, stdin is used as the source of lines to print
If sourcefile arguments are specified, stdin is ignored and all files are read in consecutively if a sourcefile is not successfully read, a warning will print to stderr, and the eventual status code will be 1, but cut will continue to read through proceeding sourcefiles
To print columns from both STDIN and a file argument, use - (dash) as a sourcefile argument to represent stdin.
Field Mode options
The fields in each line are identified by a delimiter (separator)
Set the delimiter
Set the delimiter which separates fields in the file using the –delimiter (-d) option. Setting the delimiter is optional. If not set, a default delimiter of Tab will be used.
If the -w option is provided, fields will be separated by any number of whitespace characters (Space and Tab). The output delimiter will be a Tab unless explicitly specified. Only one of -d or -w option can be specified. This is an extension adopted from FreeBSD.
Optionally Filter based on delimiter
If the –only-delimited (-s) flag is provided, only lines which contain the delimiter will be printed
Replace the delimiter
If the –output-delimiter option is provided, the argument used for it will replace the delimiter character in each line printed. This is useful for transforming tabular data - e.g. to convert a CSV to a TSV (tab-separated file)
Line endings
When the –zero-terminated (-z) option is used, cut sees \0 (null) as the ‘line ending’ character (both for the purposes of reading lines and separating printed lines) instead of \n (newline). This is useful for tabular data where some of the cells may contain newlines
echo ‘ab\0cd’ | cut -z -c 1
will result in ‘a\0c\0’
Examples
Print the fifth character on each line:
{{command}} | cut {{[-c|--characters]}} 5
Print the fifth to tenth character of each line of the specified file:
cut {{[-c|--characters]}} 5-10 {{path/to/file}}
Split each line in a file by a delimiter into fields and print fields two and six (default delimiter is TAB):
cut {{[-f|--fields]}} 2,6 {{path/to/file}}
Split each line by the specified delimiter and print all from the second field onward:
{{command}} | cut {{[-d|--delimiter]}} "{{delimiter}}" {{[-f|--fields]}} 2-
Use space as a delimiter and print only the first 3 fields:
{{command}} | cut {{[-d|--delimiter]}} " " {{[-f|--fields]}} -3
Only print lines that contain the delimiter:
{{command}} | cut {{[-d|--delimiter]}} "{{:}}" {{[-f|--fields]}} {{1}} {{[-s|--only-delimited]}}
Print specific fields of lines that use NUL to terminate lines instead of newlines:
{{find . -print0}} | cut {{[-z|--zero-terminated]}} {{[-d|--delimiter]}} "{{/}}" {{[-f|--fields]}} {{2}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
date
date [OPTION]... [+FORMAT]...
date [OPTION]... [MMDDhhmm[[CC]YY][.ss]]
FORMAT controls the output. Interpreted sequences are:
| Sequence | Description | Example |
| -------- | -------------------------------------------------------------------- | ---------------------- |
| %% | a literal % | % |
| %a | locale's abbreviated weekday name | Sun |
| %A | locale's full weekday name | Sunday |
| %b | locale's abbreviated month name | Jan |
| %B | locale's full month name | January |
| %c | locale's date and time | Thu Mar 3 23:05:25 2005|
| %C | century; like %Y, except omit last two digits | 20 |
| %d | day of month | 01 |
| %D | date; same as %m/%d/%y | 12/31/99 |
| %e | day of month, space padded; same as %_d | 3 |
| %F | full date; same as %Y-%m-%d | 2005-03-03 |
| %g | last two digits of year of ISO week number (see %G) | 05 |
| %G | year of ISO week number (see %V); normally useful only with %V | 2005 |
| %h | same as %b | Jan |
| %H | hour (00..23) | 23 |
| %I | hour (01..12) | 11 |
| %j | day of year (001..366) | 062 |
| %k | hour, space padded ( 0..23); same as %_H | 3 |
| %l | hour, space padded ( 1..12); same as %_I | 9 |
| %m | month (01..12) | 03 |
| %M | minute (00..59) | 30 |
| %n | a newline | \\n |
| %N | nanoseconds (000000000..999999999) | 123456789 |
| %p | locale's equivalent of either AM or PM; blank if not known | PM |
| %P | like %p, but lower case | pm |
| %q | quarter of year (1..4) | 1 |
| %r | locale's 12-hour clock time | 11:11:04 PM |
| %R | 24-hour hour and minute; same as %H:%M | 23:30 |
| %s | seconds since 1970-01-01 00:00:00 UTC | 1615432800 |
| %S | second (00..60) | 30 |
| %t | a tab | \\t |
| %T | time; same as %H:%M:%S | 23:30:30 |
| %u | day of week (1..7); 1 is Monday | 4 |
| %U | week number of year, with Sunday as first day of week (00..53) | 10 |
| %V | ISO week number, with Monday as first day of week (01..53) | 12 |
| %w | day of week (0..6); 0 is Sunday | 4 |
| %W | week number of year, with Monday as first day of week (00..53) | 11 |
| %x | locale's date representation | 03/03/2005 |
| %X | locale's time representation | 23:30:30 |
| %y | last two digits of year (00..99) | 05 |
| %Y | year | 2005 |
| %z | +hhmm numeric time zone | -0400 |
| %:z | +hh:mm numeric time zone | -04:00 |
| %::z | +hh:mm:ss numeric time zone | -04:00:00 |
| %:::z | numeric time zone with : to necessary precision | -04, +05:30 |
| %Z | alphabetic time zone abbreviation | EDT |
By default, date pads numeric fields with zeroes.
The following optional flags may follow '%':
* `-` (hyphen) do not pad the field
* `_` (underscore) pad with spaces
* `0` (zero) pad with zeros
* `^` use upper case if possible
* `#` use opposite case if possible
After any flags comes an optional field width, as a decimal number;
then an optional modifier, which is either
* `E` to use the locale's alternate representations if available, or
* `O` to use the locale's alternate numeric symbols if available.
Examples:
Convert seconds since the epoch (1970-01-01 UTC) to a date
date --date='@2147483647'
Show the time on the west coast of the US (use tzselect(1) to find TZ)
TZ='America/Los_Angeles' date
Print or set the system date and time
Options
--date=<STRING>,-d <STRING>-
display time described by STRING, not ‘now’
--file=<DATEFILE>,-f <DATEFILE>-
like –date; once for each line of DATEFILE
--iso-8601=<FMT>,-I <FMT>-
output date/time in ISO 8601 format.
FMT=‘date’ for date only (the default),
‘hours’, ‘minutes’, ‘seconds’, or ‘ns’
for date and time to the indicated precision.
Example: 2006-08-14T02:34:56-06:00 --resolution-
output the available resolution of timestamps
Example: 0.000000001 --rfc-email,-R-
output date and time in RFC 5322 format.
Example: Mon, 14 Aug 2006 02:34:56 -0600 --rfc-3339=<FMT>-
output date/time in RFC 3339 format.
FMT=‘date’, ‘seconds’, or ‘ns’
for date and time to the indicated precision.
Example: 2006-08-14 02:34:56-06:00 --debug-
annotate the parsed date, and warn about questionable usage to stderr
--reference=<FILE>,-r <FILE>-
display the last modification time of FILE
--set=<STRING>,-s <STRING>-
set time described by STRING
--universal,--utc,-u-
print or set Coordinated Universal Time (UTC)
Examples
Display the current date using the default locale’s format:
date +%c
Display the current date in UTC, using the ISO 8601 format:
date {{[-u|--utc]}} +%Y-%m-%dT%H:%M:%S%Z
Display the current date as a Unix timestamp (seconds since the Unix epoch):
date +%s
Convert a date specified as a Unix timestamp to the default format:
date {{[-d|--date]}} @{{1473305798}}
Convert a given date to the Unix timestamp format:
date {{[-d|--date]}} "{{2018-09-01 00:00}}" +%s {{[-u|--utc]}}
Display the current date using the RFC-3339 format (YYYY-MM-DD hh:mm:ss TZ):
date --rfc-3339 s
Set the current date using the format MMDDhhmmYYYY.ss (YYYY and .ss are optional):
date {{093023592021.59}}
Display the current ISO week number:
date +%V
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
dd
dd [OPERAND]...
dd OPTION
Copy, and optionally convert, a file system resource
Options
Operands
-
bs=BYTES : read and write up to BYTES bytes at a time (default: 512); overwrites ibs and obs.
-
cbs=BYTES : the ‘conversion block size’ in bytes. Applies to the conv=block, and conv=unblock operations.
-
conv=CONVS : a comma-separated list of conversion options or (for legacy reasons) file flags.
-
count=N : stop reading input after N ibs-sized read operations rather than proceeding until EOF. See iflag=count_bytes if stopping after N bytes is preferred
-
ibs=N : the size of buffer used for reads (default: 512)
-
if=FILE : the file used for input. When not specified, stdin is used instead
-
iflag=FLAGS : a comma-separated list of input flags which specify how the input source is treated. FLAGS may be any of the input-flags or general-flags specified below.
-
skip=N (or iseek=N) : skip N ibs-sized records into input before beginning copy/convert operations. See iflag=seek_bytes if seeking N bytes is preferred.
-
obs=N : the size of buffer used for writes (default: 512)
-
of=FILE : the file used for output. When not specified, stdout is used instead
-
oflag=FLAGS : comma separated list of output flags which specify how the output source is treated. FLAGS may be any of the output flags or general flags specified below
-
seek=N (or oseek=N) : seeks N obs-sized records into output before beginning copy/convert operations. See oflag=seek_bytes if seeking N bytes is preferred
-
status=LEVEL : controls whether volume and performance stats are written to stderr.
When unspecified, dd will print stats upon completion. An example is below.
6+0 records in 16+0 records out 8192 bytes (8.2 kB, 8.0 KiB) copied, 0.00057009 s, 14.4 MB/s The first two lines are the 'volume' stats and the final line is the 'performance' stats. The volume stats indicate the number of complete and partial ibs-sized reads, or obs-sized writes that took place during the copy. The format of the volume stats is <complete>+<partial>. If records have been truncated (see conv=block), the volume stats will contain the number of truncated records. Possible LEVEL values are: - progress : Print periodic performance stats as the copy proceeds. - noxfer : Print final volume stats, but not performance stats. - none : Do not print any stats. Printing performance stats is also triggered by the INFO signal (where supported), or the USR1 signal. Setting the POSIXLY_CORRECT environment variable to any value (including an empty value) will cause the USR1 signal to be ignored.
Conversion Options
-
ascii : convert from EBCDIC to ASCII. This is the inverse of the ebcdic option. Implies conv=unblock.
-
ebcdic : convert from ASCII to EBCDIC. This is the inverse of the ascii option. Implies conv=block.
-
ibm : convert from ASCII to EBCDIC, applying the conventions for [, ] and ~ specified in POSIX. Implies conv=block.
-
ucase : convert from lower-case to upper-case.
-
lcase : converts from upper-case to lower-case.
-
block : for each newline less than the size indicated by cbs=BYTES, remove the newline and pad with spaces up to cbs. Lines longer than cbs are truncated.
-
unblock : for each block of input of the size indicated by cbs=BYTES, remove right-trailing spaces and replace with a newline character.
-
sparse : attempts to seek the output when an obs-sized block consists of only zeros.
-
swab : swaps each adjacent pair of bytes. If an odd number of bytes is present, the final byte is omitted.
-
sync : pad each ibs-sided block with zeros. If block or unblock is specified, pad with spaces instead.
-
excl : the output file must be created. Fail if the output file is already present.
-
nocreat : the output file will not be created. Fail if the output file in not already present.
-
notrunc : the output file will not be truncated. If this option is not present, output will be truncated when opened.
-
noerror : all read errors will be ignored. If this option is not present, dd will only ignore Error::Interrupted.
-
fdatasync : data will be written before finishing.
-
fsync : data and metadata will be written before finishing.
Input flags
- count_bytes : a value to count=N will be interpreted as bytes.
- skip_bytes : a value to skip=N will be interpreted as bytes.
- fullblock : wait for ibs bytes from each read. zero-length reads are still considered EOF.
Output flags
- append : open file in append mode. Consider setting conv=notrunc as well.
- seek_bytes : a value to seek=N will be interpreted as bytes.
General Flags
- direct : use direct I/O for data.
- directory : fail unless the given input (if used as an iflag) or output (if used as an oflag) is a directory.
- dsync : use synchronized I/O for data.
- sync : use synchronized I/O for data and metadata.
- nonblock : use non-blocking I/O.
- noatime : do not update access time.
- nocache : request that OS drop cache.
- noctty : do not assign a controlling tty.
- nofollow : do not follow system links.
Examples
Make a bootable USB drive from an isohybrid file (such as archlinux-xxx.iso) and show the progress:
dd if={{path/to/file.iso}} of={{/dev/usb_drive}} status=progress
Clone a drive to another drive with 4 MiB block size and flush writes before the command terminates:
dd bs=4194304 conv=fsync if={{/dev/source_drive}} of={{/dev/dest_drive}}
Generate a file with a specific number of random bytes by using kernel random driver:
dd bs={{100}} count={{1}} if=/dev/urandom of={{path/to/random_file}}
Benchmark the sequential write performance of a disk:
dd bs={{1024}} count={{1000000}} if=/dev/zero of={{path/to/file_1GB}}
Create a system backup, save it into an IMG file (can be restored later by swapping if and of), and show the progress:
dd if={{/dev/drive_device}} of={{path/to/file.img}} status=progress
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
df
df [OPTION]... [FILE]...
Show information about the file system on which each FILE resides, or all file systems by default.
Options
--help-
Print help information.
--all,-a-
include dummy file systems
--block-size=<SIZE>,-B <SIZE>-
scale sizes by SIZE before printing them; e.g. ‘-BM’ prints sizes in units of 1,048,576 bytes
--total-
produce a grand total
--human-readable,-h-
print sizes in human readable format (e.g., 1K 234M 2G)
--si,-H-
likewise, but use powers of 1000 not 1024
--inodes,-i-
list inode information instead of block usage
-k-
like –block-size=1K
--local,-l-
limit listing to local file systems
--no-sync-
do not invoke sync before getting usage info (default)
--output=<FIELD_LIST>-
use output format defined by FIELD_LIST, or print all fields if FIELD_LIST is omitted.
--portability,-P-
use the POSIX output format
--sync-
invoke sync before getting usage info (non-windows only)
--type=<TYPE>,-t <TYPE>-
limit listing to file systems of type TYPE
--print-type,-T-
print file system type
--exclude-type=<TYPE>,-x <TYPE>-
limit listing to file systems not of type TYPE
Display values are in units of the first available SIZE from –block-size, and the DF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables. Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).
SIZE is an integer and optional unit (example: 10M is 1010241024). Units are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB,… (powers of 1000). Units can be decimal, hexadecimal, octal, binary.
Examples
Display all filesystems and their disk usage (using 512-byte units):
df
Display the filesystem containing the specified file or directory:
df {{path/to/file_or_directory}}
Use [k]ibibyte (1024 byte) units when showing size figures:
df -k
Display information in a portable way:
df -P
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
dir
Options
--help-
ls-help-print-help
--format-
ls-help-set-display-format
-C-
ls-help-display-files-columns
--long,-l-
ls-help-display-detailed-info
-x-
ls-help-list-entries-rows
--tabsize=<COLS>,-T <COLS>-
ls-help-assume-tab-stops
-m-
ls-help-list-entries-commas
--zero-
ls-help-list-entries-nul
--dired,-D-
ls-help-generate-dired-output
--hyperlink=<WHEN>-
ls-help-hyperlink-filenames
-1-
ls-help-list-one-file-per-line
-o-
ls-help-long-format-no-group
-g-
ls-help-long-no-owner
--numeric-uid-gid,-n-
ls-help-long-numeric-uid-gid
--quoting-style-
ls-help-set-quoting-style
--literal,-N-
ls-help-literal-quoting-style
--escape,-b-
ls-help-escape-quoting-style
--quote-name,-Q-
ls-help-c-quoting-style
--hide-control-chars,-q-
ls-help-replace-control-chars
--show-control-chars-
ls-help-show-control-chars
--time=<field>-
ls-help-show-time-field
-c-
ls-help-time-change
-u-
ls-help-time-access
--hide=<PATTERN>-
ls-help-hide-pattern
--ignore=<PATTERN>,-I <PATTERN>-
ls-help-ignore-pattern
--ignore-backups,-B-
ls-help-ignore-backups
--sort=<field>-
ls-help-sort-by-field
-S-
ls-help-sort-by-size
-t-
ls-help-sort-by-time
-v-
ls-help-sort-by-version
-X-
ls-help-sort-by-extension
-U-
ls-help-sort-none
--dereference,-L-
ls-help-dereference-all
--dereference-command-line-symlink-to-dir-
ls-help-dereference-dir-args
--dereference-command-line,-H-
ls-help-dereference-args
--no-group,-G-
ls-help-no-group
--author-
ls-help-author
--all,-a-
ls-help-all-files
--almost-all,-A-
ls-help-almost-all
-f-
ls-help-unsorted-all
--directory,-d-
ls-help-directory
--human-readable,-h-
ls-help-human-readable
--kibibytes,-k-
ls-help-kibibytes
--si-
ls-help-si
--block-size=<BLOCK_SIZE>-
ls-help-block-size
--inode,-i-
ls-help-print-inode
--reverse,-r-
ls-help-reverse-sort
--recursive,-R-
ls-help-recursive
--width=<COLS>,-w <COLS>-
ls-help-terminal-width
--size,-s-
ls-help-allocation-size
--color-
ls-help-color-output
--indicator-style-
ls-help-indicator-style
--classify=<when>,-F <when>-
ls-help-classify
--file-type-
ls-help-file-type
-p-
ls-help-slash-directories
--time-style=<TIME_STYLE>-
ls-help-time-style
--full-time-
ls-help-full-time
--context,-Z-
ls-help-context
--group-directories-first-
ls-help-group-directories-first
Examples
View documentation for the original command:
tldr ls
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
dircolors
dircolors [OPTION]... [FILE]
Output commands to set the LS_COLORS environment variable.
Options
--sh,--bourne-shell,-b-
output Bourne shell code to set LS_COLORS
--csh,--c-shell,-c-
output C shell code to set LS_COLORS
--print-database,-p-
print the byte counts
--print-ls-colors-
output fully escaped colors for display
If FILE is specified, read it to determine which colors to use for which file types and extensions. Otherwise, a precompiled database is used. For details on the format of these files, run ‘dircolors –print-database’
Examples
Output commands to set $LS_COLOR using default colors:
dircolors
Display each filetype with the color they would appear in ls:
dircolors --print-ls-colors
Output commands to set $LS_COLOR using colors from a file:
dircolors {{path/to/file}}
Output commands for Bourne shell:
dircolors {{[-b|--bourne-shell]}}
Output commands for C shell:
dircolors {{[-c|--c-shell]}}
View the default colors for file types and extensions:
dircolors {{[-p|--print-database]}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
dirname
dirname [OPTION] NAME...
Strip last component from file name
Options
--zero,-z-
dirname-zero-help
Output each NAME with its last non-slash component and trailing slashes removed; if NAME contains no /’s, output ‘.’ (meaning the current directory).
Examples
Calculate the parent directory of a given path:
dirname {{path/to/file_or_directory}}
Calculate the parent directory of multiple paths:
dirname {{path/to/file_or_directory1 path/to/file_or_directory2 ...}}
Delimit output with a NUL character instead of a newline (useful when combining with xargs):
dirname {{[-z|--zero]}} {{path/to/file_or_directory1 path/to/file_or_directory2 ...}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
du
du [OPTION]... [FILE]...
du [OPTION]... --files0-from=F
Estimate file space usage
Options
--help-
Print help information.
--all,-a-
write counts for all files, not just directories
--apparent-size,-A-
print apparent sizes, rather than disk usage although the apparent size is usually smaller, it may be larger due to holes in (‘sparse’) files, internal fragmentation, indirect blocks, and the like
--block-size=<SIZE>,-B <SIZE>-
scale sizes by SIZE before printing them. E.g., ‘-BM’ prints sizes in units of 1,048,576 bytes. See SIZE format below.
--bytes,-b-
equivalent to ‘–apparent-size –block-size=1’
--total,-c-
produce a grand total
--max-depth=<N>,-d <N>-
print the total for a directory (or file, with –all) only if it is N or fewer levels below the command line argument; –max-depth=0 is the same as –summarize
--human-readable,-h-
print sizes in human readable format (e.g., 1K 234M 2G)
--inodes-
list inode usage information instead of block usage like –block-size=1K
-k-
like –block-size=1K
--count-links,-l-
count sizes many times if hard linked
--dereference,-L-
follow all symbolic links
--dereference-args,-D,-H-
follow only symlinks that are listed on the command line
--no-dereference,-P-
don’t follow any symbolic links (this is the default)
-m-
like –block-size=1M
--null,-0-
end each output line with 0 byte rather than newline
--separate-dirs,-S-
do not include size of subdirectories
--summarize,-s-
display only a total for each argument
--si-
like -h, but use powers of 1000 not 1024
--one-file-system,-x-
skip directories on different file systems
--threshold=<SIZE>,-t <SIZE>-
exclude entries smaller than SIZE if positive, or entries greater than SIZE if negative
--verbose,-v-
verbose mode (option not present in GNU/Coreutils)
--exclude=<PATTERN>-
exclude files that match PATTERN
--exclude-from=<FILE>,-X <FILE>-
exclude files that match any pattern in FILE
--files0-from=<FILE>-
summarize device usage of the NUL-terminated file names specified in file F; if F is -, then read names from standard input
--time=<WORD>-
show time of the last modification of any file in the directory, or any of its subdirectories. If WORD is given, show time as WORD instead of modification time: atime, access, use, ctime, status, birth or creation
--time-style=<STYLE>-
show times using style STYLE: full-iso, long-iso, iso, +FORMAT FORMAT is interpreted like ‘date’
Display values are in units of the first available SIZE from –block-size, and the DU_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables. Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).
SIZE is an integer and optional unit (example: 10M is 1010241024). Units are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB,… (powers of 1000). Units can be decimal, hexadecimal, octal, binary.
PATTERN allows some advanced exclusions. For example, the following syntaxes are supported: ? will match only one character
- will match zero or more characters {a,b} will match a or b
Examples
List the sizes of a directory and any subdirectories, in the given unit (B/KiB/MiB):
du -{{b|k|m}} {{path/to/directory}}
List the sizes of a directory and any subdirectories, in human-readable form (i.e. auto-selecting the appropriate unit for each size):
du {{[-h|--human-readable]}} {{path/to/directory}}
Show the size of a single directory, in human-readable units:
du {{[-sh|--summarize --human-readable]}} {{path/to/directory}}
List the human-readable sizes of a directory and of all the files and directories within it:
du {{[-ah|--all --human-readable]}} {{path/to/directory}}
List the human-readable sizes of a directory and any subdirectories, up to n levels deep:
du {{[-h|--human-readable]}} {{[-d|--max-depth]}} {{n}} {{path/to/directory}}
List the human-readable size of all .jpg files in current directory, and show a cumulative total at the end:
du {{[-ch|--total --human-readable]}} *.jpg
List all files and directories (including hidden ones) above a certain threshold size (useful for investigating what is actually taking up the space):
du {{[-ah|--all --human-readable]}} {{[-t|--threshold]}} {{1G|1024M|1048576K}} .[^.]* *
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
echo
echo [OPTIONS]... [STRING]...
Display a line of text
Options
-n-
do not output the trailing newline
-e-
enable interpretation of backslash escapes
-E-
disable interpretation of backslash escapes (default)
Echo the STRING(s) to standard output.
If -e is in effect, the following sequences are recognized:
- \ backslash
- \a alert (BEL)
- \b backspace
- \c produce no further output
- \e escape
- \f form feed
- \n new line
- \r carriage return
- \t horizontal tab
- \v vertical tab
- \0NNN byte with octal value NNN (1 to 3 digits)
- \xHH byte with hexadecimal value HH (1 to 2 digits)
Examples
Print a text message. Note: Quotes are optional:
echo "{{Hello World}}"
Print a message with environment variables:
echo "{{My path is $PATH}}"
Print a message without the trailing newline:
echo -n "{{Hello World}}"
Append a message to the file:
echo "{{Hello World}}" >> {{file.txt}}
Enable interpretation of backslash escapes (special characters):
echo -e "{{Column 1\tColumn 2}}"
Print the exit status of the last executed command (Note: In Windows Command Prompt and PowerShell the equivalent commands are echo %errorlevel% and $lastexitcode respectively):
echo $?
Pass text to another program through stdin:
echo "{{Hello World}}" | {{program}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
env
env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]
Set each NAME to VALUE in the environment and run COMMAND
Options
--ignore-environment,-i-
start with an empty environment
--chdir=<DIR>,-C <DIR>-
change working directory to DIR
--null,-0-
end each output line with a 0 byte rather than a newline (only valid when printing the environment)
--file=<PATH>,-f <PATH>-
read and set variables from a “.env”-style configuration file (prior to any unset and/or set)
--unset=<NAME>,-u <NAME>-
remove variable from the environment
--debug,-v-
print verbose information for each processing step
--split-string=<S>,-S <S>-
process and split S into separate arguments; used to pass multiple arguments on shebang lines
--argv0=<a>,-a <a>-
Override the zeroth argument passed to the command being executed. Without this option a default value of
commandis used. --ignore-signal=<SIG>-
set handling of SIG signal(s) to do nothing
--default-signal=<SIG>-
reset handling of SIG signal(s) to the default action
--block-signal=<SIG>-
block delivery of SIG signal(s) while running COMMAND
--list-signal-handling-
list signal handling changes requested by preceding options
A mere - implies -i. If no COMMAND, print the resulting environment.
Examples
Show the environment:
env
Run a program. Often used in scripts after the shebang (#!) for looking up the path to the program:
env {{program}}
Clear the environment and run a program:
env {{[-i|--ignore-environment]}} {{program}}
Remove variable from the environment and run a program:
env {{[-u|--unset]}} {{variable}} {{program}}
Set a variable and run a program:
env {{variable}}={{value}} {{program}}
Set one or more variables and run a program:
env {{variable1=value variable2=value variable3=value ...}} {{program}}
Run a program under a different name:
env {{[-a|--argv0]}} {{custom_name}} {{program}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
expand
expand [OPTION]... [FILE]...
Convert tabs in each FILE to spaces, writing to standard output. With no FILE, or when FILE is -, read standard input.
Options
--initial,-i-
do not convert tabs after non blanks
--tabs=<N, LIST>,-t <N, LIST>-
have tabs N characters apart, not 8 or use comma separated list of explicit tab positions
--no-utf8,-U-
interpret input file as 8-bit ASCII rather than UTF-8
Examples
Convert tabs in each file to spaces, writing to stdout:
expand {{path/to/file}}
Convert tabs to spaces, reading from stdin:
expand
Do not convert tabs after non blanks:
expand {{[-i|--initial]}} {{path/to/file}}
Have tabs a certain number of characters apart, not 8:
expand {{[-t|--tabs]}} {{number}} {{path/to/file}}
Use a comma separated list of explicit tab positions:
expand {{[-t|--tabs]}} {{1,4,6}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
expr
expr [EXPRESSION]
expr [OPTIONS]
Print the value of EXPRESSION to standard output
Options
--version-
output version information and exit
--help-
display this help and exit
Print the value of EXPRESSION to standard output. A blank line below separates increasing precedence groups.
EXPRESSION may be:
- ARG1 | ARG2: ARG1 if it is neither null nor 0, otherwise ARG2
- ARG1 & ARG2: ARG1 if neither argument is null or 0, otherwise 0
- ARG1 < ARG2: ARG1 is less than ARG2
- ARG1 <= ARG2: ARG1 is less than or equal to ARG2
- ARG1 = ARG2: ARG1 is equal to ARG2
- ARG1 != ARG2: ARG1 is unequal to ARG2
- ARG1 >= ARG2: ARG1 is greater than or equal to ARG2
- ARG1 > ARG2: ARG1 is greater than ARG2
- ARG1 + ARG2: arithmetic sum of ARG1 and ARG2
- ARG1 - ARG2: arithmetic difference of ARG1 and ARG2
- ARG1 * ARG2: arithmetic product of ARG1 and ARG2
- ARG1 / ARG2: arithmetic quotient of ARG1 divided by ARG2
- ARG1 % ARG2: arithmetic remainder of ARG1 divided by ARG2
- STRING : REGEXP: anchored pattern match of REGEXP in STRING
- match STRING REGEXP: same as STRING : REGEXP
- substr STRING POS LENGTH: substring of STRING, POS counted from 1
- index STRING CHARS: index in STRING where any CHARS is found, or 0
- length STRING: length of STRING
-
- TOKEN: interpret TOKEN as a string, even if it is a keyword like match or an operator like /
- ( EXPRESSION ): value of EXPRESSION
Beware that many operators need to be escaped or quoted for shells. Comparisons are arithmetic if both ARGs are numbers, else lexicographical. Pattern matches return the string matched between ( and ) or null; if ( and ) are not used, they return the number of characters matched or 0.
Exit status is 0 if EXPRESSION is neither null nor 0, 1 if EXPRESSION is null or 0, 2 if EXPRESSION is syntactically invalid, and 3 if an error occurred.
Environment variables:
- EXPR_DEBUG_TOKENS=1: dump expression’s tokens
- EXPR_DEBUG_RPN=1: dump expression represented in reverse polish notation
- EXPR_DEBUG_SYA_STEP=1: dump each parser step
- EXPR_DEBUG_AST=1: dump expression represented abstract syntax tree
Examples
Get the length of a specific string:
expr length "{{string}}"
Get the substring of a string with a specific length:
expr substr "{{string}}" {{from}} {{length}}
Match a specific substring against an anchored pattern:
expr match "{{string}}" '{{pattern}}'
Get the first char position from a specific set in a string:
expr index "{{string}}" "{{chars}}"
Calculate a specific mathematic expression:
expr {{expression1}} {{+|-|*|/|%}} {{expression2}}
Get the first expression if its value is non-zero and not null otherwise get the second one:
expr {{expression1}} \| {{expression2}}
Get the first expression if both expressions are non-zero and not null otherwise get zero:
expr {{expression1}} \& {{expression2}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
factor
factor [OPTION]... [NUMBER]...
Print the prime factors of the given NUMBER(s). If none are specified, read from standard input.
Options
--exponents,-h-
Print factors in the form p^e
--help-
Print help information.
Examples
Display the prime-factorization of a number:
factor {{number}}
Take the input from stdin if no argument is specified:
echo {{number}} | factor
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
false
Immediately returns with the exit status 1. When invoked with one of the recognized options it will try to write the help or version text. Any IO error during this operation is diagnosed, yet the program will also return 1.
Options
--help-
Print help information
--version-
false-version-text
Examples
Return a non-zero exit code:
false
Make a command always exit with 1:
{{command}} && false
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
fmt
[OPTION]... [FILE]...
Reformat paragraphs from input (or standard input) to stdout.
Options
--crown-margin,-c-
fmt-crown-margin-help
--tagged-paragraph,-t-
fmt-tagged-paragraph-help
--preserve-headers,-m-
fmt-preserve-headers-help
--split-only,-s-
fmt-split-only-help
--uniform-spacing,-u-
fmt-uniform-spacing-help
--prefix=<PREFIX>,-p <PREFIX>-
fmt-prefix-help
--skip-prefix=<PSKIP>,-P <PSKIP>-
fmt-skip-prefix-help
--exact-prefix,-x-
fmt-exact-prefix-help
--exact-skip-prefix,-X-
fmt-exact-skip-prefix-help
--width=<WIDTH>,-w <WIDTH>-
fmt-width-help
--goal=<GOAL>,-g <GOAL>-
fmt-goal-help
--quick,-q-
fmt-quick-help
--tab-width=<TABWIDTH>,-T <TABWIDTH>-
fmt-tab-width-help
Examples
Reformat a file:
fmt {{path/to/file}}
Reformat a file producing output lines of (at most) n characters:
fmt {{[-w|--width]}} {{n}} {{path/to/file}}
Reformat a file without joining lines shorter than the given width together:
fmt {{[-s|--split-only]}} {{path/to/file}}
Reformat a file with uniform spacing (1 space between words and 2 spaces between paragraphs):
fmt {{[-u|--uniform-spacing]}} {{path/to/file}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
fold
fold [OPTION]... [FILE]...
Writes each file (or standard input if no files are given) to standard output whilst breaking long lines
Options
--bytes,-b-
fold-bytes-help
--characters,-c-
fold-characters-help
--spaces,-s-
fold-spaces-help
--width=<WIDTH>,-w <WIDTH>-
fold-width-help
Examples
Wrap each line to default width (80 characters):
fold {{path/to/file}}
Wrap each line to width “30”:
fold -w30 {{path/to/file}}
Wrap each line to width “5” and break the line at spaces (puts each space separated word in a new line, words with length > 5 are wrapped):
fold -w5 -s {{path/to/file}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
groups
groups [OPTION]... [USERNAME]...
Print group memberships for each USERNAME or, if no USERNAME is specified, for the current process (which may differ if the groups data‐base has changed).
Options
Examples
Print group memberships for the current user:
groups
Print group memberships for a list of users:
groups {{username1 username2 ...}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
head
head [FLAG]... [FILE]...
Print the first 10 lines of each FILE to standard output. With more than one FILE, precede each with a header giving the file name. With no FILE, or when FILE is -, read standard input.
Mandatory arguments to long flags are mandatory for short flags too.
Options
--bytes=<[-]NUM>,-c <[-]NUM>-
print the first NUM bytes of each file;
with a leading ‘-’, print all but the last
NUM bytes of each file --lines=<[-]NUM>,-n <[-]NUM>-
print the first NUM lines instead of the first 10;
with a leading ‘-’, print all but the last
NUM lines of each file --quiet,--silent,-q-
never print headers giving file names
--verbose,-v-
always print headers giving file names
--presume-input-pipe--zero-terminated,-z-
line delimiter is NUL, not newline
Examples
Output the first few lines of a file:
head -n {{count}} {{path/to/file}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
hostid
hostid [options]
Print the numeric identifier (in hexadecimal) for the current host
Options
Examples
Display the numeric identifier for the current host in hexadecimal:
hostid
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
hostname
hostname [OPTION]... [HOSTNAME]
Display or set the system’s host name.
Options
--domain,-d-
Display the name of the DNS domain if possible
--ip-address,-i-
Display the network address(es) of the host
--fqdn,-f-
Display the FQDN (Fully Qualified Domain Name) (default)
--short,-s-
Display the short hostname (the portion before the first dot) if possible
Examples
Show current host name:
hostname
Show the network address of the host name:
hostname {{[-i|--ip-address]}}
Show the FQDN (Fully Qualified Domain Name):
hostname {{[-f|--fqdn]}}
Set current host name:
hostname {{new_hostname}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
id
id [OPTION]... [USER]...
Print user and group information for each specified USER, or (when USER omitted) for the current user.
Options
--ignore,-a-
ignore, for compatibility with other versions
-A-
Display the process audit user ID and other process audit properties,
which requires privilege (not available on Linux). --user,-u-
Display only the effective user ID as a number.
--group,-g-
Display only the effective group ID as a number
--groups,-G-
Display only the different group IDs as white-space separated numbers,
in no particular order. -p-
Make the output human-readable. Each display is on a separate line.
--name,-n-
Display the name of the user or group ID for the -G, -g and -u options
instead of the number.
If any of the ID numbers cannot be mapped into
names, the number will be displayed as usual. -P-
Display the id as a password file entry.
--real,-r-
Display the real ID for the -G, -g and -u options instead of
the effective ID. --zero,-z-
delimit entries with NUL characters, not whitespace;
not permitted in default format --context,-Z-
id-context-help-enabled
The id utility displays the user and group names and numeric IDs, of the calling process, to the standard output. If the real and effective IDs are different, both are displayed, otherwise only the real ID is displayed.
If a user (login name or user ID) is specified, the user and group IDs of that user are displayed. In this case, the real and effective IDs are assumed to be the same.
Examples
Display current user’s ID (UID), group ID (GID), and groups to which they belong:
id
Display the current user identity:
id {{[-un|--user --name]}}
Display the current user identity as a number:
id {{[-u|--user]}}
Display the current primary group identity:
id {{[-gn|--group --name]}}
Display the current primary group identity as a number:
id {{[-g|--group]}}
Display all groups the current user belongs to:
id {{[-Gn|--groups --name]}}
Display an arbitrary user’s ID (UID), group ID (GID), and groups to which they belong:
id {{username}}
Skip name lookup and specify the UID number explicitly:
id +{{uid_number}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
install
install [OPTION]... [FILE]...
Copy SOURCE to DEST or multiple SOURCE(s) to the existing DIRECTORY, while setting permission modes and owner/group
Options
--backup=<CONTROL>-
make a backup of each existing destination file
-b-
like –backup but does not accept an argument
-c-
ignored
--compare,-C-
compare each pair of source and destination files, and in some cases, do not modify the destination at all
--directory,-d-
treat all arguments as directory names. create all components of the specified directories
-D-
create all leading components of DEST except the last, then copy SOURCE to DEST
--group=<GROUP>,-g <GROUP>-
set group ownership, instead of process’s current group
--mode=<MODE>,-m <MODE>-
set permission mode (as in chmod), instead of rwxr-xr-x
--owner=<OWNER>,-o <OWNER>-
set ownership (super-user only)
--preserve-timestamps,-p-
apply access/modification times of SOURCE files to corresponding destination files
--strip,-s-
strip symbol tables
--strip-program=<PROGRAM>-
program used to strip binaries
--suffix=<SUFFIX>,-S <SUFFIX>-
override the usual backup suffix
--target-directory=<DIRECTORY>,-t <DIRECTORY>-
move all SOURCE arguments into DIRECTORY
--no-target-directory,-T-
treat DEST as a normal file
--verbose,-v-
explain what is being done
--preserve-context,-P-
preserve security context
-Z-
set SELinux security context of destination file and each created directory to default type
--context=<CONTEXT>-
set security context of files and directories
--unprivileged,-U-
do not require elevated privileges to change the owner, the group, or the file flags of the destination
Examples
Copy files to the destination:
install {{path/to/source_file1 path/to/source_file2 ...}} {{path/to/destination}}
Copy files to the destination, setting their ownership:
install {{[-o|--owner]}} {{user}} {{path/to/source_file1 path/to/source_file2 ...}} {{path/to/destination}}
Copy files to the destination, setting their group ownership:
install {{[-g|--group]}} {{user}} {{path/to/source_file1 path/to/source_file2 ...}} {{path/to/destination}}
Copy files to the destination, setting their mode:
install {{[-m|--mode]}} {{+x}} {{path/to/source_file1 path/to/source_file2 ...}} {{path/to/destination}}
Copy files and apply access/modification times of source to the destination:
install {{[-p|--preserve-timestamps]}} {{path/to/source_file1 path/to/source_file2 ...}} {{path/to/destination}}
Copy files and create the directories at the destination if they don’t exist:
install -D {{path/to/source_file1 path/to/source_file2 ...}} {{path/to/destination}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
join
join [OPTION]... FILE1 FILE2
For each pair of input lines with identical join fields, write a line to standard output. The default join field is the first, delimited by blanks.
When FILE1 or FILE2 (not both) is -, read standard input.
Options
-a <FILENUM>-
also print unpairable lines from file FILENUM, where
FILENUM is 1 or 2, corresponding to FILE1 or FILE2 -v <FILENUM>-
like -a FILENUM, but suppress joined output lines
-e <EMPTY>-
replace missing input fields with EMPTY
--ignore-case,-i-
ignore differences in case when comparing fields
-j <FIELD>-
equivalent to ‘-1 FIELD -2 FIELD’
-o <FORMAT>-
obey FORMAT while constructing output line
-t <CHAR>-
use CHAR as input and output field separator
-1 <FIELD>-
join on this FIELD of file 1
-2 <FIELD>-
join on this FIELD of file 2
--check-order-
check that the input is correctly sorted, even if all input lines are pairable
--nocheck-order-
do not check that the input is correctly sorted
--header-
treat the first line in each file as field headers, print them without trying to pair them
--zero-terminated,-z-
line delimiter is NUL, not newline
Examples
Join two files on the first (default) field:
join {{path/to/file1}} {{path/to/file2}}
Join two files using a comma (instead of a space) as the field separator:
join -t ',' {{path/to/file1}} {{path/to/file2}}
Join field3 of file1 with field1 of file2:
join -1 {{3}} -2 {{1}} {{path/to/file1}} {{path/to/file2}}
Produce a line for each unpairable line for file1:
join -a {{1}} {{path/to/file1}} {{path/to/file2}}
Join a file from stdin:
cat {{path/to/file1}} | join - {{path/to/file2}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
kill
kill [OPTIONS]... PID...
Send signal to processes or list information about signals.
Options
--list,-l-
Lists signals
--table,-t-
Lists table of signals
--signal=<signal>,-s <signal>-
Sends given signal instead of SIGTERM
Examples
Terminate a program using the default SIGTERM (terminate) signal:
kill {{process_id}}
List available signal names (to be used without the SIG prefix):
kill -l
Terminate a program using the SIGHUP (hang up) signal. Many daemons will reload instead of terminating:
kill {{[-1|-HUP]}} {{process_id}}
Terminate a program using the SIGINT (interrupt) signal. This is typically initiated by the user pressing <Ctrl c>:
kill {{[-2|-INT]}} {{process_id}}
Signal the operating system to immediately terminate a program (which gets no chance to capture the signal):
kill {{[-9|-KILL]}} {{process_id}}
Signal the operating system to pause a program until a SIGCONT (“continue”) signal is received:
kill {{[-19|-STOP]}} {{process_id}}
Send a SIGUSR1 signal to all processes with the given GID (group id):
kill -SIGUSR1 -{{group_id}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
link
link FILE1 FILE2
Call the link function to create a link named FILE2 to an existing FILE1.
Options
Examples
Create a hard link from a new file to an existing file:
link {{path/to/existing_file}} {{path/to/new_file}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
ln
ln [OPTION]... [-T] TARGET LINK_NAME
ln [OPTION]... TARGET
ln [OPTION]... TARGET... DIRECTORY
ln [OPTION]... -t DIRECTORY TARGET...
Make links between files.
Options
--backup=<CONTROL>-
make a backup of each existing destination file
-b-
like –backup but does not accept an argument
--force,-f-
remove existing destination files
--interactive,-i-
prompt whether to remove existing destination files
--no-dereference,-n-
treat LINK_NAME as a normal file if it is a
symbolic link to a directory --logical,-L-
follow TARGETs that are symbolic links
--physical,-P-
make hard links directly to symbolic links
--symbolic,-s-
make symbolic links instead of hard links
--suffix=<SUFFIX>,-S <SUFFIX>-
override the usual backup suffix
--target-directory=<DIRECTORY>,-t <DIRECTORY>-
specify the DIRECTORY in which to create the links
--no-target-directory,-T-
treat LINK_NAME as a normal file always
--relative,-r-
create symbolic links relative to link location
--verbose,-v-
print name of each linked file
In the 1st form, create a link to TARGET with the name LINK_NAME. In the 2nd form, create a link to TARGET in the current directory. In the 3rd and 4th forms, create links to each TARGET in DIRECTORY. Create hard links by default, symbolic links with –symbolic. By default, each destination (name of new link) should not already exist. When creating hard links, each TARGET must exist. Symbolic links can hold arbitrary text; if later resolved, a relative link is interpreted in relation to its parent directory.
Examples
Create a symbolic link to a file or directory:
ln {{[-s|--symbolic]}} /{{path/to/file_or_directory}} {{path/to/symlink}}
Create a symbolic link relative to where the link is located:
ln {{[-s|--symbolic]}} {{path/to/file_or_directory}} {{path/to/symlink}}
Overwrite an existing symbolic link to point to a different file:
ln {{[-sf|--symbolic --force]}} /{{path/to/new_file}} {{path/to/symlink}}
Create a hard link to a file:
ln /{{path/to/file}} {{path/to/hardlink}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
logname
logname
Print user’s login name
Options
Examples
Display the currently logged in user’s name:
logname
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
ls
ls [OPTION]... [FILE]...
List directory contents. Ignore files and directories starting with a ‘.’ by default
Options
--help-
Print help information.
--format-
Set the display format.
-C-
Display the files in columns.
--long,-l-
Display detailed information.
-x-
List entries in rows instead of in columns.
--tabsize=<COLS>,-T <COLS>-
Assume tab stops at each COLS instead of 8
-m-
List entries separated by commas.
--zero-
List entries separated by ASCII NUL characters.
--dired,-D-
generate output designed for Emacs’ dired (Directory Editor) mode
--hyperlink=<WHEN>-
hyperlink file names WHEN
-1-
List one file per line.
-o-
Long format without group information.
Identical to –format=long with –no-group. -g-
Long format without owner information.
--numeric-uid-gid,-n-
-l with numeric UIDs and GIDs.
--quoting-style-
Set quoting style.
--literal,-N-
Use literal quoting style. Equivalent to
--quoting-style=literal --escape,-b-
Use escape quoting style. Equivalent to
--quoting-style=escape --quote-name,-Q-
Use C quoting style. Equivalent to
--quoting-style=c --hide-control-chars,-q-
Replace control characters with ‘?’ if they are not escaped.
--show-control-chars-
Show control characters ‘as is’ if they are not escaped.
--time=<field>-
Show time in
<field>:
access time (-u): atime, access, use;
change time (-t): ctime, status.
modification time: mtime, modification.
birth time: birth, creation; -c-
If the long listing format (e.g., -l, -o) is being used, print the
status change time (the ‘ctime’ in the inode) instead of the modification
time. When explicitly sorting by time (–sort=time or -t) or when not
using a long listing format, sort according to the status change time. -u-
If the long listing format (e.g., -l, -o) is being used, print the
status access time instead of the modification time. When explicitly
sorting by time (–sort=time or -t) or when not using a long listing
format, sort according to the access time. --hide=<PATTERN>-
do not list implied entries matching shell PATTERN (overridden by -a or -A)
--ignore=<PATTERN>,-I <PATTERN>-
do not list implied entries matching shell PATTERN
--ignore-backups,-B-
Ignore entries which end with ~.
--sort=<field>-
Sort by
<field>: name, none (-U), time (-t), size (-S), extension (-X) or width -S-
Sort by file size, largest first.
-t-
Sort by modification time (the ‘mtime’ in the inode), newest first.
-v-
Natural sort of (version) numbers in the filenames.
-X-
Sort alphabetically by entry extension.
-U-
Do not sort; list the files in whatever order they are stored in the
directory. This is especially useful when listing very large directories,
since not doing any sorting can be noticeably faster. --dereference,-L-
When showing file information for a symbolic link, show information for the
file the link references rather than the link itself. --dereference-command-line-symlink-to-dir-
Do not follow symlinks except when they link to directories and are
given as command line arguments. --dereference-command-line,-H-
Do not follow symlinks except when given as command line arguments.
--no-group,-G-
Do not show group in long format.
--author-
Show author in long format. On the supported platforms,
the author always matches the file owner. --all,-a-
Do not ignore hidden files (files with names that start with ‘.’).
--almost-all,-A-
In a directory, do not ignore all file names that start with ‘.’,
only ignore ‘.’ and ‘..’. -f-
List all files in directory order, unsorted. Equivalent to -aU. Disables –color unless explicitly specified.
--directory,-d-
Only list the names of directories, rather than listing directory contents.
This will not follow symbolic links unless one of--dereference-command-line<br />(-H),--dereference (-L), or--dereference-command-line-symlink-to-diris
specified. --human-readable,-h-
Print human readable file sizes (e.g. 1K 234M 56G).
--kibibytes,-k-
default to 1024-byte blocks for file system usage; used only with -s and per
directory totals --si-
Print human readable file sizes using powers of 1000 instead of 1024.
--block-size=<BLOCK_SIZE>-
scale sizes by BLOCK_SIZE when printing them
--inode,-i-
print the index number of each file
--reverse,-r-
Reverse whatever the sorting method is e.g., list files in reverse
alphabetical order, youngest first, smallest first, or whatever. --recursive,-R-
List the contents of all directories recursively.
--width=<COLS>,-w <COLS>-
Assume that the terminal is COLS columns wide.
--size,-s-
print the allocated size of each file, in blocks
--color-
Color output based on file type.
--indicator-style-
Append indicator with style WORD to entry names:
none (default), slash (-p), file-type (–file-type), classify (-F) --classify=<when>,-F <when>-
Append a character to each file name indicating the file type. Also, for
regular files that are executable, append ‘*’. The file type indicators are
‘/’ for directories, ‘@’ for symbolic links, ‘|’ for FIFOs, ‘=’ for sockets,
‘>’ for doors, and nothing for regular files. when may be omitted, or one of:
none - Do not classify. This is the default.
auto - Only classify if standard output is a terminal.
always - Always classify.
Specifying –classify and no when is equivalent to –classify=always. This will
not follow symbolic links listed on the command line unless the
–dereference-command-line (-H), –dereference (-L), or
–dereference-command-line-symlink-to-dir options are specified. --file-type-
Same as –classify, but do not append ‘*’
-p-
Append / indicator to directories.
--time-style=<TIME_STYLE>-
time/date format with -l; see TIME_STYLE below
--full-time-
like -l –time-style=full-iso
--context,-Z-
print any security context of each file
--group-directories-first-
group directories before files; can be augmented with
a –sort option, but any use of –sort=none (-U) disables grouping
The TIME_STYLE argument can be full-iso, long-iso, iso, locale or +FORMAT. FORMAT is interpreted like in date. Also the TIME_STYLE environment variable sets the default style to use.
Examples
List files one per line:
ls -1
List all files, including hidden files:
ls {{[-a|--all]}}
List files with a trailing symbol to indicate file type (directory/, symbolic_link@, executable*, …):
ls {{[-F|--classify]}}
List all files in [l]ong format (permissions, ownership, size, and modification date):
ls {{[-la|-l --all]}}
List files in [l]ong format with size displayed using human-readable units (KiB, MiB, GiB):
ls {{[-lh|-l --human-readable]}}
List files in [l]ong format, sorted by [S]ize (descending) recursively:
ls {{[-lSR|-lS --recursive]}}
List files in [l]ong format, sorted by [t]ime the file was modified and in reverse order (oldest first):
ls {{[-ltr|-lt --reverse]}}
Only list directories:
ls {{[-d|--directory]}} */
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
md5sum
md5sum [OPTIONS] [FILE]...
Print or check the MD5 checksums
Options
--binary,-b--check,-c-
ck-common-help-check
--warn,-w-
ck-common-help-warn
--status-
ck-common-help-status
--quiet-
ck-common-help-quiet
--ignore-missing-
ck-common-help-ignore-missing
--strict-
ck-common-help-strict
--tag-
ck-common-help-tag
--text,-t-
ck-common-help-text
--zero,-z-
ck-common-help-zero
Examples
Calculate the MD5 checksum for one or more files:
md5sum {{path/to/file1 path/to/file2 ...}}
Calculate and save the list of MD5 checksums to a file:
md5sum {{path/to/file1 path/to/file2 ...}} > {{path/to/file.md5}}
Calculate an MD5 checksum from stdin:
{{command}} | md5sum
Read a file of MD5 checksums and filenames and verify all files have matching checksums:
md5sum {{[-c|--check]}} {{path/to/file.md5}}
Only show a message for missing files or when verification fails:
md5sum {{[-c|--check]}} --quiet {{path/to/file.md5}}
Only show a message when verification fails, ignoring missing files:
md5sum --ignore-missing {{[-c|--check]}} --quiet {{path/to/file.md5}}
Check a known MD5 checksum of a file:
echo {{known_md5_checksum_of_the_file}} {{path/to/file}} | md5sum {{[-c|--check]}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
mkdir
mkdir [OPTION]... DIRECTORY...
Create the given DIRECTORY(ies) if they do not exist
Options
--mode,-m-
set file mode (not implemented on windows)
--parents,-p-
make parent directories as needed
--verbose,-v-
print a message for each printed directory
-Z-
set SELinux security context of each created directory to the default type
--context=<CTX>-
like -Z, or if CTX is specified then set the SELinux or SMACK security context to CTX
Each MODE is of the form [ugoa]*(-+=)+|[-+=]?[0-7]+.
Examples
Create specific directories:
mkdir {{path/to/directory1 path/to/directory2 ...}}
Create specific directories and their parents if needed:
mkdir {{[-p|--parents]}} {{path/to/directory1 path/to/directory2 ...}}
Create directories with specific permissions:
mkdir {{[-m|--mode]}} {{rwxrw-r--}} {{path/to/directory1 path/to/directory2 ...}}
Create multiple nested directories recursively:
mkdir {{[-p|--parents]}} {{path/to/{a,b}/{x,y,z}/{h,i,j}}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
mkfifo
mkfifo [OPTION]... NAME...
Create a FIFO with the given name.
Options
--mode=<MODE>,-m <MODE>-
file permissions for the fifo
-Z-
set the SELinux security context to default type
--context=<CTX>-
like -Z, or if CTX is specified then set the SELinux or SMACK security context to CTX
Examples
Create a named pipe at a given path:
mkfifo {{path/to/pipe}}
Send data through a named pipe and send the command to the background:
echo "{{Hello World}}" > {{path/to/pipe}} &
Receive data through a named pipe:
cat {{path/to/pipe}}
Share your terminal session in real-time:
mkfifo {{path/to/pipe}}; script {{[-f|--flush]}} {{path/to/pipe}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
mknod
mknod [OPTION]... NAME TYPE [MAJOR MINOR]
Create the special file NAME of the given TYPE.
Options
--mode=<MODE>,-m <MODE>-
set file permission bits to MODE, not a=rw - umask
-
name of the new file
-
type of the new file (b, c, u or p)
-
major file type
-
minor file type
-Z-
set SELinux security context of each created directory to the default type
--context=<CTX>-
like -Z, or if CTX is specified then set the SELinux or SMACK security context to CTX
Mandatory arguments to long options are mandatory for short options too. -m, –mode=MODE set file permission bits to MODE, not a=rw - umask
Both MAJOR and MINOR must be specified when TYPE is b, c, or u, and they must be omitted when TYPE is p. If MAJOR or MINOR begins with 0x or 0X, it is interpreted as hexadecimal; otherwise, if it begins with 0, as octal; otherwise, as decimal. TYPE may be:
- b create a block (buffered) special file
- c, u create a character (unbuffered) special file
- p create a FIFO
NOTE: your shell may have its own version of mknod, which usually supersedes the version described here. Please refer to your shell’s documentation for details about the options it supports.
Examples
Create a block device:
sudo mknod {{path/to/device_file}} b {{major_device_number}} {{minor_device_number}}
Create a character device:
sudo mknod {{path/to/device_file}} c {{major_device_number}} {{minor_device_number}}
Create a FIFO (queue) device:
sudo mknod {{path/to/device_file}} p
Create a device file with default SELinux security context:
sudo mknod {{[-Z|--context]}} {{path/to/device_file}} {{type}} {{major_device_number}} {{minor_device_number}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
mktemp
mktemp [OPTION]... [TEMPLATE]
Create a temporary file or directory.
Options
--directory,-d-
Make a directory instead of a file
--dry-run,-u-
do not create anything; merely print a name (unsafe)
--quiet,-q-
Fail silently if an error occurs.
--suffix=<SUFFIX>-
append SUFFIX to TEMPLATE; SUFFIX must not contain a path separator. This option is implied if TEMPLATE does not end with X.
-p <DIR>-
short form of –tmpdir
--tmpdir=<DIR>-
interpret TEMPLATE relative to DIR; if DIR is not specified, use $TMPDIR ($TMP on windows) if set, else /tmp. With this option, TEMPLATE must not be an absolute name; unlike with -t, TEMPLATE may contain slashes, but mktemp creates only the final component
-t-
Generate a template (using the supplied prefix and TMPDIR (TMP on windows) if set) to create a filename template [deprecated]
Examples
Create an empty temporary file and print its absolute path:
mktemp
Use a custom directory if $TMPDIR is not set (the default is platform-dependent, but usually /tmp):
mktemp -p /{{path/to/temporary_directory}}
Use a custom path template (Xs are replaced with random alphanumeric characters):
mktemp {{/tmp/example.XXXXXXXX}}
Use a custom file name template:
mktemp -t {{example.XXXXXXXX}}
Create an empty temporary directory and print its absolute path:
mktemp -d
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
more
more [OPTIONS] FILE...
Display the contents of a text file
Options
--silent,-d-
Display help instead of ringing bell when an illegal key is pressed
--logical,-l-
Do not pause after any line containing a ^L (form feed)
--exit-on-eof,-e-
Exit on End-Of-File
--no-pause,-f-
Count logical lines, rather than screen lines
--print-over,-p-
Do not scroll, clear screen and display text
--clean-print,-c-
Do not scroll, display text and clean line ends
--squeeze,-s-
Squeeze multiple blank lines into one
--plain,-u-
Suppress underlining
--lines=<number>,-n <number>-
The number of lines per screen full
--number-
Same as –lines option argument
--from-line=<number>,-F <number>-
Start displaying each file at line number
--pattern=<pattern>,-P <pattern>-
The string to be searched in each file before starting to display it
-
Path to the files to be read
Examples
Open a file:
more {{path/to/file}}
Display a specific line:
more +{{line_number}} {{path/to/file}}
Go to the next page:
<Space>
Search for a string (press <n> to go to the next match):
</>{{something}}<Enter>
Exit:
<q>
Display help about interactive commands:
<h>
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
mv
mv [OPTION]... [-T] SOURCE DEST
mv [OPTION]... SOURCE... DIRECTORY
mv [OPTION]... -t DIRECTORY SOURCE...
Move SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.
Options
--force,-f-
do not prompt before overwriting
--interactive,-i-
prompt before override
--no-clobber,-n-
do not overwrite an existing file
--strip-trailing-slashes-
remove any trailing slashes from each SOURCE argument
--backup=<CONTROL>-
make a backup of each existing destination file
-b-
like –backup but does not accept an argument
--suffix=<SUFFIX>,-S <SUFFIX>-
override the usual backup suffix
--update-
move only when the SOURCE file is newer than the destination file or when the destination file is missing
-u-
like –update but does not accept an argument
--target-directory=<DIRECTORY>,-t <DIRECTORY>-
move all SOURCE arguments into DIRECTORY
--no-target-directory,-T-
treat DEST as a normal file
--verbose,-v-
explain what is being done
--progress,-g-
Display a progress bar.
Note: this feature is not supported by GNU coreutils. -Z-
set SELinux security context of destination file to default type
--context=<CTX>-
like -Z, or if CTX is specified then set the SELinux security context to CTX
--debug-
explain how a file is copied. Implies -v
When specifying more than one of -i, -f, -n, only the final one will take effect.
Do not move a non-directory that has an existing destination with the same or newer modification timestamp; instead, silently skip the file without failing. If the move is across file system boundaries, the comparison is to the source timestamp truncated to the resolutions of the destination file system and of the system calls used to update timestamps; this avoids duplicate work if several mv -u commands are executed with the same source and destination. This option is ignored if the -n or –no-clobber option is also specified. which gives more control over which existing files in the destination are replaced, and its value can be one of the following:
- all This is the default operation when an –update option is not specified, and results in all existing files in the destination being replaced.
- none This is similar to the –no-clobber option, in that no files in the destination are replaced, but also skipping a file does not induce a failure.
- older This is the default operation when –update is specified, and results in files being replaced if they’re older than the corresponding source file.
Examples
Rename a file or directory when the target is not an existing directory:
mv {{path/to/source}} {{path/to/target}}
Move a file or directory into an existing directory:
mv {{path/to/source}} {{path/to/existing_directory}}
Move multiple files into an existing directory, keeping the filenames unchanged:
mv {{path/to/source1 path/to/source2 ...}} {{path/to/existing_directory}}
Do not prompt for confirmation before overwriting existing files:
mv {{[-f|--force]}} {{path/to/source}} {{path/to/target}}
Prompt for confirmation interactively before overwriting existing files, regardless of file permissions:
mv {{[-i|--interactive]}} {{path/to/source}} {{path/to/target}}
Do not overwrite existing files at the target:
mv {{[-n|--no-clobber]}} {{path/to/source}} {{path/to/target}}
Move files in verbose mode, showing files after they are moved:
mv {{[-v|--verbose]}} {{path/to/source}} {{path/to/target}}
Specify target directory so that you can use external tools to gather movable files:
{{find /var/log -type f -name '*.log' -print0}} | {{xargs -0}} mv {{[-t|--target-directory]}} {{path/to/target_directory}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
nice
nice [OPTION] [COMMAND [ARG]...]
Run COMMAND with an adjusted niceness, which affects process scheduling. With no COMMAND, print the current niceness. Niceness values range from -20 (most favorable to the process) to 19 (least favorable to the process).
Options
--adjustment,-n-
add N to the niceness (default is 10)
Examples
Print the current niceness value:
nice
Increment the current niceness value by 10:
nice nice
Launch a program with lowered priority:
nice -{{niceness_value}} {{command}}
Launch a program with heightened priority:
sudo nice --{{niceness_value}} {{command}}
Define the priority with an explicit option:
nice {{[-n|--adjustment]}} {{niceness_value}} {{command}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
nl
nl [OPTION]... [FILE]...
Number lines of files
Options
--help-
Print help information.
--body-numbering=<STYLE>,-b <STYLE>-
use STYLE for numbering body lines
--section-delimiter=<CC>,-d <CC>-
use CC for separating logical pages
--footer-numbering=<STYLE>,-f <STYLE>-
use STYLE for numbering footer lines
--header-numbering=<STYLE>,-h <STYLE>-
use STYLE for numbering header lines
--line-increment=<NUMBER>,-i <NUMBER>-
line number increment at each line
--join-blank-lines=<NUMBER>,-l <NUMBER>-
group of NUMBER empty lines counted as one
--number-format=<FORMAT>,-n <FORMAT>-
insert line numbers according to FORMAT
--no-renumber,-p-
do not reset line numbers at logical pages
--number-separator=<STRING>,-s <STRING>-
add STRING after (possible) line number
--starting-line-number=<NUMBER>,-v <NUMBER>-
first line number on each logical page
--number-width=<NUMBER>,-w <NUMBER>-
use NUMBER columns for line numbers
STYLE is one of:
- a number all lines
- t number only nonempty lines
- n number no lines
- pBRE number only lines that contain a match for the basic regular expression, BRE
FORMAT is one of:
- ln left justified, no leading zeros
- rn right justified, no leading zeros
- rz right justified, leading zeros
Examples
Number non-blank lines in a file:
nl {{path/to/file}}
Read from stdin:
{{command}} | nl -
Number [a]ll [b]ody lines including blank lines or do [n]ot number [b]ody lines:
nl -b {{a|n}} {{path/to/file}}
Number only the [b]ody lines that match a basic regex (BRE) [p]attern:
nl -b p'FooBar[0-9]' {{path/to/file}}
Use a specific [i]ncrement for line numbering:
nl -i {{increment}} {{path/to/file}}
Specify the line numbering format to [r]ight or [l]eft justified, keeping leading [z]eros or [n]ot:
nl -n {{rz|ln|rn}}
Specify the line numbering’s [w]idth (6 by default):
nl -w {{col_width}} {{path/to/file}}
Use a specific string to [s]eparate the line numbers from the lines (TAB by default):
nl -s {{separator}} {{path/to/file}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
nohup
nohup COMMAND [ARG]...
nohup OPTION
Run COMMAND ignoring hangup signals.
Options
If standard input is terminal, it’ll be replaced with /dev/null. If standard output is terminal, it’ll be appended to nohup.out instead, or $HOME/nohup.out, if nohup.out open failed. If standard error is terminal, it’ll be redirected to stdout.
Examples
Run a process that can live beyond the terminal:
nohup {{command}} {{argument1 argument2 ...}}
Launch nohup in background mode:
nohup {{command}} {{argument1 argument2 ...}} &
Run a shell script that can live beyond the terminal:
nohup {{path/to/script.sh}} &
Run a process and write the output to a specific file:
nohup {{command}} {{argument1 argument2 ...}} > {{path/to/output_file}} &
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
nproc
nproc [OPTIONS]...
Print the number of cores available to the current process. If the OMP_NUM_THREADS or OMP_THREAD_LIMIT environment variables are set, then they will determine the minimum and maximum returned value respectively.
Options
--all-
print the number of cores available to the system
--ignore=<N>-
ignore up to N cores
Examples
Display the number of available processing units:
nproc
Display the number of installed processing units, including any inactive ones:
nproc --all
If possible, subtract a given number of units from the returned value:
nproc --ignore {{count}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
numfmt
numfmt [OPTION]... [NUMBER]...
Convert numbers from/to human-readable strings
Options
--debug-
print warnings about invalid input
--delimiter=<X>,-d <X>-
use X instead of whitespace for field delimiter
--field=<FIELDS>-
replace the numbers in these input fields; see FIELDS below
--format=<FORMAT>-
use printf style floating-point FORMAT; see FORMAT below for details
--from=<UNIT>-
auto-scale input numbers to UNITs; see UNIT below
--from-unit=<N>-
specify the input unit size
--to=<UNIT>-
auto-scale output numbers to UNITs; see UNIT below
--to-unit=<N>-
the output unit size
--padding=<N>-
pad the output to N characters; positive N will right-align; negative N will left-align; padding is ignored if the output is wider than N; the default is to automatically pad if a whitespace is found
--header=<N>-
print (without converting) the first N header lines; N defaults to 1 if not specified
--round=<METHOD>-
use METHOD for rounding when scaling
--suffix=<SUFFIX>-
print SUFFIX after each formatted number, and accept inputs optionally ending with SUFFIX
--unit-separator=<STRING>-
use STRING to separate the number from any unit when printing; by default, no separator is used
--invalid=<INVALID>-
set the failure mode for invalid input
--zero-terminated,-z-
line delimiter is NUL, not newline
UNIT options:
-
none: no auto-scaling is done; suffixes will trigger an error
-
auto: accept optional single/two letter suffix:
1K = 1000, 1Ki = 1024, 1M = 1000000, 1Mi = 1048576,
-
si: accept optional single letter suffix:
1K = 1000, 1M = 1000000, …
-
iec: accept optional single letter suffix:
1K = 1024, 1M = 1048576, …
-
iec-i: accept optional two-letter suffix:
1Ki = 1024, 1Mi = 1048576, …
-
FIELDS supports cut(1) style field ranges:
N N’th field, counted from 1 N- from N’th field, to end of line N-M from N’th to M’th field (inclusive) -M from first to M’th field (inclusive)
- all fields
Multiple fields/ranges can be separated with commas
FORMAT must be suitable for printing one floating-point argument %f. Optional quote (%’f) will enable –grouping (if supported by current locale). Optional width value (%10f) will pad output. Optional zero (%010f) width will zero pad the number. Optional negative values (%-10f) will left align. Optional precision (%.1f) will override the input determined precision.
Examples
Convert 1.5K (SI Units) to 1500:
numfmt --from si 1.5K
Convert 1500 to 1.5K (SI Units):
numfmt --to si 1500
Convert 1.5K (IEC Units) to 1536:
numfmt --from iec 1.5K
Use appropriate conversion based on the suffix:
numfmt --from auto {{1.5Ki}}
Convert 5th field (1-indexed) to IEC Units without converting header:
ls -l | numfmt --header=1 --field 5 --to iec
Convert to IEC units, pad with 5 characters, left aligned:
du {{[-s|--summarize]}} * | numfmt --to iec --format "%-5f"
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
od
od [OPTION]... [--] [FILENAME]...
od [-abcdDefFhHiIlLoOsxX] [FILENAME] [[+][0x]OFFSET[.][b]]
od --traditional [OPTION]... [FILENAME] [[+][0x]OFFSET[.][b] [[+][0x]LABEL[.][b]]]
Dump files in octal and other formats
Options
--help-
Print help information.
--address-radix=<RADIX>,-A <RADIX>-
Select the base in which file offsets are printed.
--skip-bytes=<BYTES>,-j <BYTES>-
Skip bytes input bytes before formatting and writing.
--read-bytes=<BYTES>,-N <BYTES>-
limit dump to BYTES input bytes
--endian=<big|little>-
byte order to use for multi-byte formats
--strings=<BYTES>,-S <BYTES>-
output strings of at least BYTES graphic chars. 3 is assumed when BYTES is not specified.
-a-
named characters, ignoring high-order bit
-b-
octal bytes
-c-
ASCII characters or backslash escapes
-d-
unsigned decimal 2-byte units
-D-
unsigned decimal 4-byte units
-o-
octal 2-byte units
-I-
decimal 8-byte units
-L-
decimal 8-byte units
-i-
decimal 4-byte units
-l-
decimal 8-byte units
-x-
hexadecimal 2-byte units
-h-
hexadecimal 2-byte units
-O-
octal 4-byte units
-s-
decimal 2-byte units
-X-
hexadecimal 4-byte units
-H-
hexadecimal 4-byte units
-e-
floating point double precision (64-bit) units
-f-
floating point single precision (32-bit) units
-F-
floating point double precision (64-bit) units
--format=<TYPE>,-t <TYPE>-
select output format or formats
--output-duplicates,-v-
do not use * to mark line suppression
--width=<BYTES>,-w <BYTES>-
output BYTES bytes per output line. 32 is implied when BYTES is not
specified. --traditional-
compatibility mode with one input, offset and label.
Displays data in various human-readable formats. If multiple formats are specified, the output will contain all formats in the order they appear on the command line. Each format will be printed on a new line. Only the line containing the first format will be prefixed with the offset.
If no filename is specified, or it is “-”, stdin will be used. After a “–”, no more options will be recognized. This allows for filenames starting with a “-”.
If a filename is a valid number which can be used as an offset in the second form, you can force it to be recognized as a filename if you include an option like “-j0”, which is only valid in the first form.
RADIX is one of o,d,x,n for octal, decimal, hexadecimal or none.
BYTES is decimal by default, octal if prefixed with a “0”, or hexadecimal if prefixed with “0x”. The suffixes b, KB, K, MB, M, GB, G, will multiply the number with 512, 1000, 1024, 1000^2, 1024^2, 1000^3, 1024^3, 1000^2, 1024^2.
OFFSET and LABEL are octal by default, hexadecimal if prefixed with “0x” or decimal if a “.” suffix is added. The “b” suffix will multiply with 512.
TYPE contains one or more format specifications consisting of: a for printable 7-bits ASCII c for utf-8 characters or octal for undefined characters d[SIZE] for signed decimal f[SIZE] for floating point o[SIZE] for octal u[SIZE] for unsigned decimal x[SIZE] for hexadecimal SIZE is the number of bytes which can be the number 1, 2, 4, 8 or 16, or C, S, I, L for 1, 2, 4, 8 bytes for integer types, or F, D, L for 4, 8, 16 bytes for floating point. Any type specification can have a “z” suffix, which will add a ASCII dump at the end of the line.
If an error occurred, a diagnostic message will be printed to stderr, and the exit code will be non-zero.
Examples
Display file using default settings: octal format, 8 bytes per line, byte offsets in octal, and duplicate lines replaced with *:
od {{path/to/file}}
Display file in verbose mode, i.e. without replacing duplicate lines with *:
od {{[-v|--output-duplicates]}} {{path/to/file}}
Display file in hexadecimal format (2-byte units), with byte offsets in decimal format:
od {{[-t|--format]}} {{x}} {{[-A|--address-radix]}} {{d}} {{[-v|--output-duplicates]}} {{path/to/file}}
Display file in hexadecimal format (1-byte units), and 4 bytes per line:
od {{[-t|--format]}} {{x1}} {{[-w|--width=]}}4 {{[-v|--output-duplicates]}} {{path/to/file}}
Display file in hexadecimal format along with its character representation, and do not print byte offsets:
od {{[-t|--format]}} {{xz}} {{[-A|--address-radix]}} {{n}} {{[-v|--output-duplicates]}} {{path/to/file}}
Read only 100 bytes of a file starting from the 500th byte:
od {{[-N|--read-bytes]}} 100 {{[-j|--skip-bytes]}} 500 {{[-v|--output-duplicates]}} {{path/to/file}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
paste
paste [OPTIONS] [FILE]...
Write lines consisting of the sequentially corresponding lines from each FILE, separated by TABs, to standard output.
Options
--serial,-s-
paste one file at a time instead of in parallel
--delimiters=<LIST>,-d <LIST>-
reuse characters from LIST instead of TABs
--zero-terminated,-z-
line delimiter is NUL, not newline
Examples
Join all the lines into a single line, using TAB as delimiter:
paste {{[-s|--serial]}} {{path/to/file}}
Join all the lines into a single line, using the specified delimiter:
paste {{[-s|--serial]}} {{[-d|--delimiters]}} {{delimiter}} {{path/to/file}}
Merge two files side by side, each in its column, using TAB as delimiter:
paste {{path/to/file1}} {{path/to/file2}}
Merge two files side by side, each in its column, using the specified delimiter:
paste {{[-d|--delimiters]}} {{delimiter}} {{path/to/file1}} {{path/to/file2}}
Merge two files, with lines added alternatively:
paste {{[-d|--delimiters]}} '\n' {{path/to/file1}} {{path/to/file2}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
pathchk
pathchk [OPTION]... NAME...
Check whether file names are valid or portable
Options
-p-
check for most POSIX systems
-P-
check for empty names and leading “-”
--portability-
check for all POSIX systems (equivalent to -p -P)
Examples
Check pathnames for validity in the current system:
pathchk {{path1 path2 ...}}
Check pathnames for validity on a wider range of POSIX compliant systems:
pathchk -p {{path1 path2 ...}}
Check pathnames for validity on all POSIX compliant systems:
pathchk {{[-p -P|--portability]}} {{path1 path2 ...}}
Only check for empty pathnames or leading dashes (-):
pathchk -P {{path1 path2 ...}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
pinky
pinky [OPTION]... [USER]...
Displays brief user information on Unix-based systems
Options
-l-
produce long format output for the specified USERs
-b-
omit the user’s home directory and shell in long format
-h-
omit the user’s project file in long format
-p-
omit the user’s plan file in long format
-s-
do short format output, this is the default
-f-
omit the line of column headings in short format
-w-
omit the user’s full name in short format
-i-
omit the user’s full name and remote host in short format
-q-
omit the user’s full name, remote host and idle time in short format
--lookup-
attempt to canonicalize hostnames via DNS
--help-
Print help information
Examples
Display details about the current user:
pinky
Display details for a specific user:
pinky {{user}}
Display details in the long format:
pinky {{user}} -l
Omit the user’s home directory and shell in long format:
pinky {{user}} -lb
Omit the user’s project file in long format:
pinky {{user}} -lh
Omit the column headings in short format:
pinky {{user}} -f
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
pr
pr [OPTION]... [FILE]...
paginate or columnate FILE(s) for printing
Options
--pages=<FIRST_PAGE[:LAST_PAGE]>-
Begin and stop printing with page FIRST_PAGE[:LAST_PAGE]
--header=<STRING>,-h <STRING>-
Use the string header to replace the file name
in the header line. --date-format=<FORMAT>,-D <FORMAT>-
Use ‘date’-style FORMAT for the header date.
--double-space,-d-
Produce output that is double spaced. An extra
<newline>
character is output following every<newline>found in the input. --number-lines=<[char][width]>,-n <[char][width]>-
Provide width digit line numbering. The default for width,
if not specified, is 5. The number occupies the first width column
positions of each text column or each line of -m output. If char
(any non-digit character) is given, it is appended to the line number
to separate it from whatever follows. The default for char is a<tab>.
Line numbers longer than width columns are truncated. --first-line-number=<NUMBER>,-N <NUMBER>-
start counting with NUMBER at 1st line of first page printed
--omit-header,-t-
Write neither the five-line identifying header nor the five-line
trailer usually supplied for each page. Quit writing after the last line
of each file without spacing to the end of the page. --omit-pagination,-T-
omit page headers and trailers, eliminate any pagination
by form feeds set in input files --length=<PAGE_LENGTH>,-l <PAGE_LENGTH>-
Override the 66-line default (default number of lines of text 56,
and with -F 63) and reset the page length to lines. If lines is not
greater than the sum of both the header and trailer depths (in lines),
the pr utility shall suppress both the header and trailer, as if the -t
option were in effect. --no-file-warnings,-r-
omit warning when a file cannot be opened
--form-feed,-F-
Use a
<form-feed>for new pages, instead of the default behavior that
uses a sequence of<newline>s. --width=<width>,-w <width>-
Set the width of the line to width column positions for multiple
text-column output only. If the -w option is not specified and the -s option
is not specified, the default width shall be 72. If the -w option is not specified
and the -s option is specified, the default width shall be 512. --page-width=<width>,-W <width>-
set page width to PAGE_WIDTH (72) characters always,
truncate lines, except -J option is set, no interference
with -S or -s --across,-a-
Modify the effect of the - column option so that the columns are filled
across the page in a round-robin order (for example, when column is 2, the
first input line heads column 1, the second heads column 2, the third is the
second line in column 1, and so on). -b--column=<column>-
Produce multi-column output that is arranged in column columns
(the default shall be 1) and is written down each column in the order in which
the text is received from the input file. This option should not be used with -m.
The options -e and -i shall be assumed for multiple text-column output. Whether
or not text columns are produced with identical vertical lengths is unspecified,
but a text column shall never exceed the length of the page (see the -l option).
When used with -t, use the minimum number of lines to write the output. --separator=<char>,-s <char>-
Separate text columns by the single character char instead of by the
appropriate number of<space>s (default for char is the<tab>character). --sep-string=<string>,-S <string>-
separate columns by STRING,
without -S: Default separator<TAB>with -J and<space>
otherwise (same as -S" "), no effect on column options --merge,-m-
Merge files. Standard output shall be formatted so the pr utility
writes one line from each file specified by a file operand, side by side
into text columns of equal fixed widths, in terms of the number of column
positions. Implementations shall support merging of at least nine file operands. --indent=<margin>,-o <margin>-
Each line of output shall be preceded by offset
<space>s. If the -o
option is not specified, the default offset shall be zero. The space taken is
in addition to the output line width (see the -w option below). -J-
merge full lines, turns off -W line truncation, no column
alignment, –sep-string[=STRING] sets separators --help-
Print help information
--expand-tabs=<[CHAR][WIDTH]>,-e <[CHAR][WIDTH]>-
expand input CHARs (TABs) to tab WIDTH (8)
If no FILE(s) are given, or if FILE is -, read standard input.
When creating multicolumn output, columns will be of equal width. When using the ‘-s’ option to separate columns, the default separator is a single tab character. When using the ‘-S’ option to separate columns, the default separator is a single space character.
Examples
Print multiple files with a default header and footer:
pr {{path/to/file1 path/to/file2 ...}}
Print with a custom centered header:
pr {{[-h|--header]}} "{{header}}" {{path/to/file1 path/to/file2 ...}}
Print with numbered lines and a custom date format:
pr {{[-n|--number-lines]}} {{[-D|--date-format]}} "{{format}}" {{path/to/file1 path/to/file2 ...}}
Print all files together, one in each column, without a header or footer:
pr {{[-m|--merge]}} {{[-T|--omit-pagination]}} {{path/to/file1 path/to/file2 ...}}
Print, beginning at page 2 up to page 5, with a given page length (including header and footer):
pr +2:5 {{[-l|--length]}} {{page_length}} {{path/to/file1 path/to/file2 ...}}
Print with an offset for each line and a truncating custom page width:
pr {{[-o|--indent]}} {{offset}} {{[-W|--page_width]}} {{width}} {{path/to/file1 path/to/file2 ...}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
printenv
printenv [OPTION]... [VARIABLE]...
Display the values of the specified environment VARIABLE(s), or (with no VARIABLE) display name and value pairs for them all.
Options
--null,-0-
end each output line with 0 byte rather than newline
Examples
Display key-value pairs of all environment variables:
printenv
Display the value of a specific variable:
printenv {{HOME}}
Display the value of a variable and end with NUL instead of newline:
printenv {{[-0|--null]}} {{HOME}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
printf
printf FORMAT [ARGUMENT]...
printf OPTION
Print output based off of the format string and proceeding arguments.
Options
--help-
Print help information
--version-
Print version information
basic anonymous string templating:
prints format string at least once, repeating as long as there are remaining arguments output prints escaped literals in the format string as character literals output replaces anonymous fields with the next unused argument, formatted according to the field.
Prints the , replacing escaped character sequences with character literals and substitution field sequences with passed arguments
literally, with the exception of the below escaped character sequences, and the substitution sequences described further down.
ESCAPE SEQUENCES
The following escape sequences, organized here in alphabetical order, will print the corresponding character literal:
-
" double quote
-
\ backslash
-
\a alert (BEL)
-
\b backspace
-
\c End-of-Input
-
\e escape
-
\f form feed
-
\n new line
-
\r carriage return
-
\t horizontal tab
-
\v vertical tab
-
\NNN byte with value expressed in octal value NNN (1 to 3 digits) values greater than 256 will be treated
-
\xHH byte with value expressed in hexadecimal value NN (1 to 2 digits)
-
\uHHHH Unicode (IEC 10646) character with value expressed in hexadecimal value HHHH (4 digits)
-
\uHHHH Unicode character with value expressed in hexadecimal value HHHH (8 digits)
-
%% a single %
SUBSTITUTIONS
SUBSTITUTION QUICK REFERENCE
Fields
-
%s: string
-
%b: string parsed for literals second parameter is max length
-
%c: char no second parameter
-
%i or %d: 64-bit integer
-
%u: 64 bit unsigned integer
-
%x or %X: 64-bit unsigned integer as hex
-
%o: 64-bit unsigned integer as octal second parameter is min-width, integer output below that width is padded with leading zeroes
-
%q: ARGUMENT is printed in a format that can be reused as shell input, escaping non-printable characters with the proposed POSIX $‘’ syntax.
-
%f or %F: decimal floating point value
-
%e or %E: scientific notation floating point value
-
%g or %G: shorter of specially interpreted decimal or SciNote floating point value. second parameter is -max places after decimal point for floating point output -max number of significant digits for scientific notation output
parameterizing fields
examples:
printf ‘%4.3i’ 7
It has a first parameter of 4 and a second parameter of 3 and will result in ’ 007’
printf ‘%.1s’ abcde
It has no first parameter and a second parameter of 1 and will result in ‘a’
printf ‘%4c’ q
It has a first parameter of 4 and no second parameter and will result in ’ q’
The first parameter of a field is the minimum width to pad the output to if the output is less than this absolute value of this width, it will be padded with leading spaces, or, if the argument is negative, with trailing spaces. the default is zero.
The second parameter of a field is particular to the output field type. defaults can be found in the full substitution help below
special prefixes to numeric arguments
- 0: (e.g. 010) interpret argument as octal (integer output fields only)
- 0x: (e.g. 0xABC) interpret argument as hex (numeric output fields only)
- ': (e.g. 'a) interpret argument as a character constant
HOW TO USE SUBSTITUTIONS
Substitutions are used to pass additional argument(s) into the FORMAT string, to be formatted a particular way. E.g.
printf ‘the letter %X comes before the letter %X’ 10 11
will print
the letter A comes before the letter B
because the substitution field %X means ‘take an integer argument and write it as a hexadecimal number’
Passing more arguments than are in the format string will cause the format string to be repeated for the remaining substitutions
printf ‘it is %i F in %s \n’ 22 Portland 25 Boston 27 New York
will print
it is 22 F in Portland it is 25 F in Boston it is 27 F in Boston
If a format string is printed but there are less arguments remaining than there are substitution fields, substitution fields without an argument will default to empty strings, or for numeric fields the value 0
AVAILABLE SUBSTITUTIONS
This program, like GNU coreutils printf, interprets a modified subset of the POSIX C printf spec, a quick reference to substitutions is below.
STRING SUBSTITUTIONS
All string fields have a ‘max width’ parameter %.3s means ‘print no more than three characters of the original input’
-
%s: string
-
%b: escaped string - the string will be checked for any escaped literals from the escaped literal list above, and translate them to literal characters. e.g. \n will be transformed into a newline character. One special rule about %b mode is that octal literals are interpreted differently In arguments passed by %b, pass octal-interpreted literals must be in the form of \0NNN instead of \NNN. (Although, for legacy reasons, octal literals in the form of \NNN will still be interpreted and not throw a warning, you will have problems if you use this for a literal whose code begins with zero, as it will be viewed as in \0NNN form.)
-
%q: escaped string - the string in a format that can be reused as input by most shells. Non-printable characters are escaped with the POSIX proposed ‘$‘’’ syntax, and shell meta-characters are quoted appropriately. This is an equivalent format to ls –quoting=shell-escape output.
CHAR SUBSTITUTIONS
The character field does not have a secondary parameter.
- %c: a single character
INTEGER SUBSTITUTIONS
All integer fields have a ‘pad with zero’ parameter %.4i means an integer which if it is less than 4 digits in length, is padded with leading zeros until it is 4 digits in length.
-
%d or %i: 64-bit integer
-
%u: 64-bit unsigned integer
-
%x or %X: 64-bit unsigned integer printed in Hexadecimal (base 16) %X instead of %x means to use uppercase letters for ‘a’ through ‘f’
-
%o: 64-bit unsigned integer printed in octal (base 8)
FLOATING POINT SUBSTITUTIONS
All floating point fields have a ‘max decimal places / max significant digits’ parameter %.10f means a decimal floating point with 7 decimal places past 0 %.10e means a scientific notation number with 10 significant digits %.10g means the same behavior for decimal and Sci. Note, respectively, and provides the shortest of each’s output.
Like with GNU coreutils, the value after the decimal point is these outputs is parsed as a double first before being rendered to text. For both implementations do not expect meaningful precision past the 18th decimal place. When using a number of decimal places that is 18 or higher, you can expect variation in output between GNU coreutils printf and this printf at the 18th decimal place of +/- 1
-
%f: floating point value presented in decimal, truncated and displayed to 6 decimal places by default. There is not past-double behavior parity with Coreutils printf, values are not estimated or adjusted beyond input values.
-
%e or %E: floating point value presented in scientific notation 7 significant digits by default %E means use to use uppercase E for the mantissa.
-
%g or %G: floating point value presented in the shortest of decimal and scientific notation behaves differently from %f and %E, please see posix printf spec for full details, some examples of different behavior: Sci Note has 6 significant digits by default Trailing zeroes are removed Instead of being truncated, digit after last is rounded
Like other behavior in this utility, the design choices of floating point behavior in this utility is selected to reproduce in exact the behavior of GNU coreutils’ printf from an inputs and outputs standpoint.
USING PARAMETERS
Most substitution fields can be parameterized using up to 2 numbers that can be passed to the field, between the % sign and the field letter.
The 1st parameter always indicates the minimum width of output, it is useful for creating columnar output. Any output that would be less than this minimum width is padded with leading spaces The 2nd parameter is proceeded by a dot. You do not have to use parameters
SPECIAL FORMS OF INPUT
For numeric input, the following additional forms of input are accepted besides decimal:
Octal (only with integer): if the argument begins with a 0 the proceeding characters will be interpreted as octal (base 8) for integer fields
Hexadecimal: if the argument begins with 0x the proceeding characters will be interpreted will be interpreted as hex (base 16) for any numeric fields for float fields, hexadecimal input results in a precision limit (in converting input past the decimal point) of 10^-15
Character Constant: if the argument begins with a single quote character, the first byte of the next character will be interpreted as an 8-bit unsigned integer. If there are additional bytes, they will throw an error (unless the environment variable POSIXLY_CORRECT is set)
Examples
Print a text message:
printf "{{%s\n}}" "{{Hello world}}"
Print an integer in bold blue:
printf "{{\e[1;34m%.3d\e[0m\n}}" {{42}}
Print a float number with the Unicode Euro sign:
printf "{{\u20AC %.2f\n}}" {{123.4}}
Print a text message composed with environment variables:
printf "{{var1: %s\tvar2: %s\n}}" "{{$VAR1}}" "{{$VAR2}}"
Store a formatted message in a variable (does not work on Zsh):
printf -v {{myvar}} {{"This is %s = %d\n" "a year" 2016}}
Print a hexadecimal, octal, and scientific number:
printf "{{hex=%x octal=%o scientific=%e\n}}" 0x{{FF}} 0{{377}} {{100000}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
ptx
ptx [OPTION]... [INPUT]...
ptx -G [OPTION]... [INPUT [OUTPUT]]
Produce a permuted index of file contents Output a permuted index, including context, of the words in the input files. Mandatory arguments to long options are mandatory for short options too. With no FILE, or when FILE is -, read standard input. Default is ‘-F /’.
Options
--auto-reference,-A-
output automatically generated references
--traditional,-G-
behave more like System V ‘ptx’
--flag-truncation=<STRING>,-F <STRING>-
use STRING for flagging line truncations
--macro-name=<STRING>,-M <STRING>-
macro name to use instead of ‘xx’
--format-O-
generate output as roff directives
-T-
generate output as TeX directives
--right-side-refs,-R-
put references at right, not counted in -w
--sentence-regexp=<REGEXP>,-S <REGEXP>-
for end of lines or end of sentences
--word-regexp=<REGEXP>,-W <REGEXP>-
use REGEXP to match each keyword
--break-file=<FILE>,-b <FILE>-
word break characters in this FILE
--ignore-case,-f-
fold lower case to upper case for sorting
--gap-size=<NUMBER>,-g <NUMBER>-
gap size in columns between output fields
--ignore-file=<FILE>,-i <FILE>-
read ignore word list from FILE
--only-file=<FILE>,-o <FILE>-
read only word list from this FILE
--references=<FILE>,-r <FILE>-
first field of each line is a reference
--typeset-mode,-t-
change the default width from 72 to 100
--width=<NUMBER>,-w <NUMBER>-
output width in columns, reference excluded
Examples
Generate a permuted index where the first field of each line is an index reference:
ptx {{[-r|--references]}} {{path/to/file}}
Generate a permuted index with automatically generated index references:
ptx {{[-A|--auto-reference]}} {{path/to/file}}
Generate a permuted index with a fixed width:
ptx {{[-w|--width]}} {{width_in_columns}} {{path/to/file}}
Generate a permuted index with a list of filtered words:
ptx {{[-o|--only-file]}} {{path/to/filter}} {{path/to/file}}
Generate a permuted index with SYSV-style behaviors:
ptx {{[-G|--traditional]}} {{path/to/file}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
pwd
pwd [OPTION]...
Display the full filename of the current working directory.
Options
--logical,-L-
use PWD from environment, even if it contains symlinks
--physical,-P-
avoid all symlinks
Examples
Print the current directory:
pwd
Print the current directory, and resolve all symlinks (i.e. show the “physical” path):
pwd {{[-P|--physical]}}
Display help:
pwd --help
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
readlink
readlink [OPTION]... [FILE]...
Print value of a symbolic link or canonical file name.
Options
--canonicalize,-f-
canonicalize by following every symlink in every component of the given name recursively; all but the last component must exist
--canonicalize-existing,-e-
canonicalize by following every symlink in every component of the given name recursively, all components must exist
--canonicalize-missing,-m-
canonicalize by following every symlink in every component of the given name recursively, without requirements on components existence
--no-newline,-n-
do not output the trailing delimiter
--quiet,-q-
suppress most error messages
--silent,-s-
suppress most error messages
--verbose,-v-
report error message
--zero,-z-
separate output with NUL rather than newline
Examples
Get the actual file to which the symlink points:
readlink {{path/to/file}}
Get the absolute path to a file:
readlink {{[-f|--canonicalize]}} {{path/to/file}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
realpath
realpath [OPTION]... FILE...
Print the resolved path
Options
--quiet,-q-
Do not print warnings for invalid paths
--strip,--no-symlinks,-s-
Only strip ‘.’ and ‘..’ components, but don’t resolve symbolic links
--zero,-z-
Separate output filenames with \0 rather than newline
--logical,-L-
resolve ‘..’ components before symlinks
--physical,-P-
resolve symlinks as encountered (default)
--canonicalize,-E-
all but the last component must exist (default)
--canonicalize-existing,-e-
canonicalize by following every symlink in every component of the given name recursively, all components must exist
--canonicalize-missing,-m-
canonicalize by following every symlink in every component of the given name recursively, without requirements on components existence
--relative-to=<DIR>-
print the resolved path relative to DIR
--relative-base=<DIR>-
print absolute paths unless paths below DIR
Examples
Display the absolute path for a file or directory:
realpath {{path/to/file_or_directory}}
Require all path components to exist:
realpath {{[-e|--canonicalize-existing]}} {{path/to/file_or_directory}}
Resolve .. components before symlinks:
realpath {{[-L|--logical]}} {{path/to/file_or_directory}}
Disable symlink expansion:
realpath {{[-s|--no-symlinks]}} {{path/to/file_or_directory}}
Suppress error messages:
realpath {{[-q|--quiet]}} {{path/to/file_or_directory}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
rm
rm [OPTION]... FILE...
Remove (unlink) the FILE(s)
Options
--force,-f-
ignore nonexistent files and arguments, never prompt
-i-
prompt before every removal
-I-
prompt once before removing more than three files, or when removing recursively.
Less intrusive than -i, while still giving some protection against most mistakes --interactive=<WHEN>-
prompt according to WHEN: never, once (-I), or always (-i). Without WHEN,
prompts always --one-file-system-
when removing a hierarchy recursively, skip any directory that is on a file
system different from that of the corresponding command line argument (NOT
IMPLEMENTED) --no-preserve-root-
do not treat ‘/’ specially
--preserve-root-
do not remove ‘/’ (default)
--recursive,-r,-R-
remove directories and their contents recursively
--dir,-d-
remove empty directories
--verbose,-v-
explain what is being done
--progress,-g-
display a progress bar. Note: this feature is not supported by GNU coreutils.
--presume-input-tty
By default, rm does not remove directories. Use the –recursive (-r or -R) option to remove each listed directory, too, along with all of its contents
To remove a file whose name starts with a ‘-’, for example ‘-foo’, use one of these commands: rm – -foo
rm ./-foo
Note that if you use rm to remove a file, it might be possible to recover some of its contents, given sufficient expertise and/or time. For greater assurance that the contents are truly unrecoverable, consider using shred.
Examples
Remove specific files:
rm {{path/to/file1 path/to/file2 ...}}
Remove specific files ignoring nonexistent ones:
rm {{[-f|--force]}} {{path/to/file1 path/to/file2 ...}}
Remove specific files interactively prompting before each removal:
rm {{[-i|--interactive]}} {{path/to/file1 path/to/file2 ...}}
Remove specific files printing info about each removal:
rm {{[-v|--verbose]}} {{path/to/file1 path/to/file2 ...}}
Remove specific files and directories recursively:
rm {{[-r|--recursive]}} {{path/to/file_or_directory1 path/to/file_or_directory2 ...}}
Remove empty directories (this is considered the safe method):
rm {{[-d|--dir]}} {{path/to/directory}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
rmdir
rmdir [OPTION]... DIRECTORY...
Remove the DIRECTORY(ies), if they are empty.
Options
--ignore-fail-on-non-empty-
ignore each failure that is solely because a directory is non-empty
--parents,-p-
remove DIRECTORY and its ancestors; e.g., ‘rmdir -p a/b/c’ is similar to rmdir a/b/c a/b a
--verbose,-v-
output a diagnostic for every directory processed
Examples
Remove specific directories:
rmdir {{path/to/directory1 path/to/directory2 ...}}
Remove specific nested directories recursively:
rmdir {{[-p|--parents]}} {{path/to/directory1 path/to/directory2 ...}}
Clean a directory of empty directories:
rmdir *
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
runcon
runcon CONTEXT COMMAND [ARG...]
runcon [-c] [-u USER] [-r ROLE] [-t TYPE] [-l RANGE] COMMAND [ARG...]
Run command with specified security context under SELinux enabled systems.
Options
--compute,-c-
Compute process transition context before modifying.
--user=<USER>,-u <USER>-
Set user USER in the target security context.
--role=<ROLE>,-r <ROLE>-
Set role ROLE in the target security context.
--type=<TYPE>,-t <TYPE>-
Set type TYPE in the target security context.
--range=<RANGE>,-l <RANGE>-
Set range RANGE in the target security context.
Run COMMAND with completely-specified CONTEXT, or with current or transitioned security context modified by one or more of LEVEL, ROLE, TYPE, and USER.
If none of –compute, –type, –user, –role or –range is specified, then the first argument is used as the complete context.
Note that only carefully-chosen contexts are likely to successfully run.
If neither CONTEXT nor COMMAND is specified, the current security context is printed.
Examples
Print the security context of the current execution context:
runcon
Specify the domain to run a command in:
runcon {{[-t|--type]}} {{domain}}_t {{command}}
Specify the context role to run a command with:
runcon {{[-r|--role]}} {{role}}_r {{command}}
Specify the full context to run a command with:
runcon {{user}}_u:{{role}}_r:{{domain}}_t {{command}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
seq
seq [OPTION]... LAST
seq [OPTION]... FIRST LAST
seq [OPTION]... FIRST INCREMENT LAST
Display numbers from FIRST to LAST, in steps of INCREMENT.
Options
--separator,-s-
Separator character (defaults to \n)
--terminator,-t-
Terminator character (defaults to \n)
--equal-width,-w-
Equalize widths of all numbers by padding with zeros
--format,-f-
use printf style floating-point FORMAT
Examples
Print a sequence from 1 to 10:
seq 10
Print a sequence from 10 to 20:
seq 10 20
Print every 3rd number from 5 to 20:
seq 5 3 20
Separate the output with a space instead of a newline:
seq {{[-s|--separator]}} " " {{5 3 20}}
Format output width to a minimum of 4 digits padding with zeros as necessary:
seq {{[-f|--format]}} "%04g" {{5 3 20}}
Print all numbers with the same width:
seq {{[-w|--equal-width]}} {{5 3 20}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
sha1sum
sha1sum [OPTIONS] [FILE]...
Print or check the SHA1 checksums
Options
--binary,-b--check,-c-
ck-common-help-check
--warn,-w-
ck-common-help-warn
--status-
ck-common-help-status
--quiet-
ck-common-help-quiet
--ignore-missing-
ck-common-help-ignore-missing
--strict-
ck-common-help-strict
--tag-
ck-common-help-tag
--text,-t-
ck-common-help-text
--zero,-z-
ck-common-help-zero
Examples
Calculate the SHA1 checksum for one or more files:
sha1sum {{path/to/file1 path/to/file2 ...}}
Calculate and save the list of SHA1 checksums to a file:
sha1sum {{path/to/file1 path/to/file2 ...}} > {{path/to/file.sha1}}
Calculate a SHA1 checksum from stdin:
{{command}} | sha1sum
Read a file of SHA1 checksums and filenames and verify all files have matching checksums:
sha1sum {{[-c|--check]}} {{path/to/file.sha1}}
Only show a message for missing files or when verification fails:
sha1sum {{[-c|--check]}} --quiet {{path/to/file.sha1}}
Only show a message when verification fails, ignoring missing files:
sha1sum --ignore-missing {{[-c|--check]}} --quiet {{path/to/file.sha1}}
Check a known SHA1 checksum of a file:
echo {{known_sha1_checksum_of_the_file}} {{path/to/file}} | sha1sum {{[-c|--check]}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
sha224sum
sha224sum [OPTIONS] [FILE]...
Print or check the SHA224 checksums
Options
--binary,-b--check,-c-
ck-common-help-check
--warn,-w-
ck-common-help-warn
--status-
ck-common-help-status
--quiet-
ck-common-help-quiet
--ignore-missing-
ck-common-help-ignore-missing
--strict-
ck-common-help-strict
--tag-
ck-common-help-tag
--text,-t-
ck-common-help-text
--zero,-z-
ck-common-help-zero
Examples
Calculate the SHA224 checksum for one or more files:
sha224sum {{path/to/file1 path/to/file2 ...}}
Calculate and save the list of SHA224 checksums to a file:
sha224sum {{path/to/file1 path/to/file2 ...}} > {{path/to/file.sha224}}
Calculate a SHA224 checksum from stdin:
{{command}} | sha224sum
Read a file of SHA224 checksums and filenames and verify all files have matching checksums:
sha224sum {{[-c|--check]}} {{path/to/file.sha224}}
Only show a message for missing files or when verification fails:
sha224sum {{[-c|--check]}} --quiet {{path/to/file.sha224}}
Only show a message when verification fails, ignoring missing files:
sha224sum --ignore-missing {{[-c|--check]}} --quiet {{path/to/file.sha224}}
Check a known SHA224 checksum of a file:
echo {{known_sha224_checksum_of_the_file}} {{path/to/file}} | sha224sum {{[-c|--check]}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
sha256sum
sha256sum [OPTIONS] [FILE]...
Print or check the SHA256 checksums
Options
--binary,-b--check,-c-
ck-common-help-check
--warn,-w-
ck-common-help-warn
--status-
ck-common-help-status
--quiet-
ck-common-help-quiet
--ignore-missing-
ck-common-help-ignore-missing
--strict-
ck-common-help-strict
--tag-
ck-common-help-tag
--text,-t-
ck-common-help-text
--zero,-z-
ck-common-help-zero
Examples
Calculate the SHA256 checksum for one or more files:
sha256sum {{path/to/file1 path/to/file2 ...}}
Calculate and save the list of SHA256 checksums to a file:
sha256sum {{path/to/file1 path/to/file2 ...}} > {{path/to/file.sha256}}
Calculate a SHA256 checksum from stdin:
{{command}} | sha256sum
Read a file of SHA256 checksums and filenames and verify all files have matching checksums:
sha256sum {{[-c|--check]}} {{path/to/file.sha256}}
Only show a message for missing files or when verification fails:
sha256sum {{[-c|--check]}} --quiet {{path/to/file.sha256}}
Only show a message when verification fails, ignoring missing files:
sha256sum --ignore-missing {{[-c|--check]}} --quiet {{path/to/file.sha256}}
Check a known SHA256 checksum of a file:
echo {{known_sha256_checksum_of_the_file}} {{path/to/file}} | sha256sum {{[-c|--check]}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
sha384sum
sha384sum [OPTIONS] [FILE]...
Print or check the SHA384 checksums
Options
--binary,-b--check,-c-
ck-common-help-check
--warn,-w-
ck-common-help-warn
--status-
ck-common-help-status
--quiet-
ck-common-help-quiet
--ignore-missing-
ck-common-help-ignore-missing
--strict-
ck-common-help-strict
--tag-
ck-common-help-tag
--text,-t-
ck-common-help-text
--zero,-z-
ck-common-help-zero
Examples
Calculate the SHA384 checksum for one or more files:
sha384sum {{path/to/file1 path/to/file2 ...}}
Calculate and save the list of SHA384 checksums to a file:
sha384sum {{path/to/file1 path/to/file2 ...}} > {{path/to/file.sha384}}
Calculate a SHA384 checksum from stdin:
{{command}} | sha384sum
Read a file of SHA384 checksums and filenames and verify all files have matching checksums:
sha384sum {{[-c|--check]}} {{path/to/file.sha384}}
Only show a message for missing files or when verification fails:
sha384sum {{[-c|--check]}} --quiet {{path/to/file.sha384}}
Only show a message when verification fails, ignoring missing files:
sha384sum --ignore-missing {{[-c|--check]}} --quiet {{path/to/file.sha384}}
Check a known SHA384 checksum of a file:
echo {{known_sha384_checksum_of_the_file}} {{path/to/file}} | sha384sum {{[-c|--check]}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
sha512sum
sha512sum [OPTIONS] [FILE]...
Print or check the SHA512 checksums
Options
--binary,-b--check,-c-
ck-common-help-check
--warn,-w-
ck-common-help-warn
--status-
ck-common-help-status
--quiet-
ck-common-help-quiet
--ignore-missing-
ck-common-help-ignore-missing
--strict-
ck-common-help-strict
--tag-
ck-common-help-tag
--text,-t-
ck-common-help-text
--zero,-z-
ck-common-help-zero
Examples
Calculate the SHA512 checksum for one or more files:
sha512sum {{path/to/file1 path/to/file2 ...}}
Calculate and save the list of SHA512 checksums to a file:
sha512sum {{path/to/file1 path/to/file2 ...}} > {{path/to/file.sha512}}
Calculate a SHA512 checksum from stdin:
{{command}} | sha512sum
Read a file of SHA512 checksums and filenames and verify all files have matching checksums:
sha512sum {{[-c|--check]}} {{path/to/file.sha512}}
Only show a message for missing files or when verification fails:
sha512sum {{[-c|--check]}} --quiet {{path/to/file.sha512}}
Only show a message when verification fails, ignoring missing files:
sha512sum --ignore-missing {{[-c|--check]}} --quiet {{path/to/file.sha512}}
Check a known SHA512 checksum of a file:
echo {{known_sha512_checksum_of_the_file}} {{path/to/file}} | sha512sum {{[-c|--check]}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
shred
shred [OPTION]... FILE...
Overwrite the specified FILE(s) repeatedly, in order to make it harder for even very expensive hardware probing to recover the data.
Options
--force,-f-
shred-force-help
--iterations=<NUMBER>,-n <NUMBER>-
shred-iterations-help
--size=<N>,-s <N>-
shred-size-help
-u-
shred-deallocate-help
--remove=<HOW>-
shred-remove-help
--verbose,-v-
shred-verbose-help
--exact,-x-
shred-exact-help
--zero,-z-
shred-zero-help
--random-source-
shred-random-source-help
Delete FILE(s) if –remove (-u) is specified. The default is not to remove the files because it is common to operate on device files like /dev/hda, and those files usually should not be removed.
CAUTION: Note that shred relies on a very important assumption: that the file system overwrites data in place. This is the traditional way to do things, but many modern file system designs do not satisfy this assumption. The following are examples of file systems on which shred is not effective, or is not guaranteed to be effective in all file system modes:
-
log-structured or journal file systems, such as those supplied with AIX and Solaris (and JFS, ReiserFS, XFS, Ext3, etc.)
-
file systems that write redundant data and carry on even if some writes fail, such as RAID-based file systems
-
file systems that make snapshots, such as Network Appliance’s NFS server
-
file systems that cache in temporary locations, such as NFS version 3 clients
-
compressed file systems
In the case of ext3 file systems, the above disclaimer applies (and shred is
thus of limited effectiveness) only in data=journal mode, which journals file
data in addition to just metadata. In both the data=ordered (default) and
data=writeback modes, shred works as usual. Ext3 journal modes can be changed
by adding the data=something option to the mount options for a particular
file system in the /etc/fstab file, as documented in the mount man page (man mount).
In addition, file system backups and remote mirrors may contain copies of the file that cannot be removed, and that will allow a shredded file to be recovered later.
Examples
Overwrite a file:
shred {{path/to/file}}
Overwrite a file and show progress on the screen:
shred {{[-v|--verbose]}} {{path/to/file}}
Overwrite a file, leaving zeros instead of random data:
shred {{[-z|--zero]}} {{path/to/file}}
Overwrite a file a specific number of times:
shred {{[-n|--iterations]}} {{25}} {{path/to/file}}
Overwrite a file and remove it:
shred {{[-u|--remove]}} {{path/to/file}}
Overwrite a file 100 times, add a final overwrite with zeros, remove the file after overwriting it, and show verbose progress on the screen:
shred {{[-vzu|--verbose --zero --remove]}} {{[-n|--iterations]}} 100 {{path/to/file}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
shuf
shuf [OPTION]... [FILE]
shuf -e [OPTION]... [ARG]...
shuf -i LO-HI [OPTION]...
Shuffle the input by outputting a random permutation of input lines. Each output permutation is equally likely. With no FILE, or when FILE is -, read standard input.
Options
--echo,-e-
treat each ARG as an input line
--input-range=<LO-HI>,-i <LO-HI>-
treat each number LO through HI as an input line
--head-count=<COUNT>,-n <COUNT>-
output at most COUNT lines
--output=<FILE>,-o <FILE>-
write result to FILE instead of standard output
--random-seed=<STRING>-
seed with STRING for reproducible output
--random-source=<FILE>-
get random bytes from FILE
--repeat,-r-
output lines can be repeated
--zero-terminated,-z-
line delimiter is NUL, not newline
Examples
Randomize the order of lines in a file and output the result:
shuf {{path/to/file}}
Only output the first 5 entries of the result:
shuf {{[-n|--head-count]}} 5 {{path/to/file}}
Write the output to another file:
shuf {{path/to/input_file}} {{[-o|--output]}} {{path/to/output_file}}
Generate 3 random numbers in the range 1-10 (inclusive, numbers can repeat):
shuf {{[-n|--head-count]}} 3 {{[-i|--input-range]}} 1-10 {{[-r|--repeat]}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
sleep
sleep NUMBER[SUFFIX]...
sleep OPTION
Pause for NUMBER seconds.
Options
-
pause for NUMBER seconds
Pause for NUMBER seconds. SUFFIX may be ‘s’ for seconds (the default), ‘m’ for minutes, ‘h’ for hours or ‘d’ for days. Unlike most implementations that require NUMBER be an integer, here NUMBER may be an arbitrary floating point number. Given two or more arguments, pause for the amount of time specified by the sum of their values.
Examples
Delay in seconds:
sleep {{seconds}}
Execute a specific command after 20 seconds delay:
sleep 20 && {{command}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
sort
sort [OPTION]... [FILE]...
Display sorted concatenation of all FILE(s). With no FILE, or when FILE is -, read standard input.
Options
--help-
Print help information.
--version-
Print version information.
--sort--human-numeric-sort,-h-
compare according to human readable sizes, eg 1M > 100k
--month-sort,-M-
compare according to month name abbreviation
--numeric-sort,-n-
compare according to string numerical value
--general-numeric-sort,-g-
compare according to string general numerical value
--version-sort,-V-
Sort by SemVer version number, eg 1.12.2 > 1.1.2
--random-sort,-R-
shuffle in random order
--random-source=<FILE>-
use FILE as a source of random data
--dictionary-order,-d-
consider only blanks and alphanumeric characters
--merge,-m-
merge already sorted files; do not sort
--check,-c-
check for sorted input; do not sort
--check-silent,-C-
exit successfully if the given file is already sorted, and exit with status 1 otherwise.
--ignore-case,-f-
fold lower case to upper case characters
--ignore-nonprinting,-i-
ignore nonprinting characters
--ignore-leading-blanks,-b-
ignore leading blanks when finding sort keys in each line
--output=<FILENAME>,-o <FILENAME>-
write output to FILENAME instead of stdout
--reverse,-r-
reverse the output
--stable,-s-
stabilize sort by disabling last-resort comparison
--unique,-u-
output only the first of an equal run
--key,-k-
sort by a key
--field-separator,-t-
custom separator for -k
--zero-terminated,-z-
line delimiter is NUL, not newline
--parallel=<NUM_THREADS>-
change the number of threads running concurrently to NUM_THREADS
--buffer-size=<SIZE>,-S <SIZE>-
sets the maximum SIZE of each segment in number of sorted items
--temporary-directory=<DIR>,-T <DIR>-
use DIR for temporaries, not $TMPDIR or /tmp
--compress-program=<PROG>-
compress temporary files with PROG, decompress with PROG -d; PROG has to take input from stdin and output to stdout
--batch-size=<N_MERGE>-
Merge at most N_MERGE inputs at once.
--files0-from=<NUL_FILE>-
read input from the files specified by NUL-terminated NUL_FILE
--debug-
underline the parts of the line that are actually used for sorting
The key format is FIELD[.CHAR][OPTIONS][,FIELD[.CHAR]][OPTIONS].
Fields by default are separated by the first whitespace after a non-whitespace character. Use -t to specify a custom separator. In the default case, whitespace is appended at the beginning of each field. Custom separators however are not included in fields.
FIELD and CHAR both start at 1 (i.e. they are 1-indexed). If there is no end specified after a comma, the end will be the end of the line. If CHAR is set 0, it means the end of the field. CHAR defaults to 1 for the start position and to 0 for the end position.
Valid options are: MbdfhnRrV. They override the global options for this key.
Examples
Sort a file in ascending order:
sort {{path/to/file}}
Sort a file in descending order:
sort {{[-r|--reverse]}} {{path/to/file}}
Sort a file in case-insensitive way:
sort {{[-f|--ignore-case]}} {{path/to/file}}
Sort a file using numeric rather than alphabetic order:
sort {{[-n|--numeric-sort]}} {{path/to/file}}
Sort /etc/passwd by the 3rd field onward of each line numerically, using : as a field separator:
sort {{[-t|--field-separator]}} : {{[-k|--key]}} 3n /etc/passwd
As above, but when items in the 3rd field are equal, sort by the 4th field by numbers with exponents:
sort {{[-t|--field-separator]}} : {{[-k|--key]}} 3,3n {{[-k|--key]}} 4,4g /etc/passwd
Sort a file preserving only unique lines:
sort {{[-u|--unique]}} {{path/to/file}}
Sort a file, printing the output to the specified output file (can be used to sort a file in-place):
sort {{[-o|--output]}} {{path/to/output_file}} {{path/to/input_file}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
split
split [OPTION]... [INPUT [PREFIX]]
Create output files containing consecutive or interleaved sections of input
Options
--bytes=<SIZE>,-b <SIZE>-
put SIZE bytes per output file
--line-bytes=<SIZE>,-C <SIZE>-
put at most SIZE bytes of lines per output file
--lines=<NUMBER>,-l <NUMBER>-
put NUMBER lines/records per output file
--number=<CHUNKS>,-n <CHUNKS>-
generate CHUNKS output files; see explanation below
--additional-suffix=<SUFFIX>-
additional SUFFIX to append to output file names
--filter=<COMMAND>-
write to shell COMMAND; file name is $FILE (Currently not implemented for Windows)
--elide-empty-files,-e-
do not generate empty output files with ‘-n’
-d-
use numeric suffixes starting at 0, not alphabetic
--numeric-suffixes=<FROM>-
same as -d, but allow setting the start value
-x-
use hex suffixes starting at 0, not alphabetic
--hex-suffixes=<FROM>-
same as -x, but allow setting the start value
--suffix-length=<N>,-a <N>-
generate suffixes of length N (default 2)
--verbose-
print a diagnostic just before each output file is opened
--separator=<SEP>,-t <SEP>-
use SEP instead of newline as the record separator; ‘\0’ (zero) specifies the NUL character
--io-blksize
Output fixed-size pieces of INPUT to PREFIXaa, PREFIXab, …; default size is 1000, and default PREFIX is ‘x’. With no INPUT, or when INPUT is -, read standard input.
The SIZE argument is an integer and optional unit (example: 10K is 10*1024). Units are K,M,G,T,P,E,Z,Y,R,Q (powers of 1024) or KB,MB,… (powers of 1000). Binary prefixes can be used, too: KiB=K, MiB=M, and so on.
CHUNKS may be:
- N split into N files based on size of input
- K/N output Kth of N to stdout
- l/N split into N files without splitting lines/records
- l/K/N output Kth of N to stdout without splitting lines/records
- r/N like ‘l’ but use round robin distribution
- r/K/N likewise but only output Kth of N to stdout
Examples
Split a file, each split having 10 lines (except the last split):
split {{[-l|--lines]}} 10 {{path/to/file}}
Split a file into 5 files. File is split such that each split has same size (except the last split):
split {{[-n|--number]}} 5 {{path/to/file}}
Split a file with 512 bytes in each split (except the last split; use 512k for kilobytes and 512m for megabytes):
split {{[-b|--bytes]}} 512 {{path/to/file}}
Split a file with at most 512 bytes in each split without breaking lines:
split {{[-C|--line-bytes]}} 512 {{path/to/file}}
Split into multiple files from stdin:
gzip {{[-cd|--stdout --decompress]}} {{path/to/compressed_file.gz}} | split {{[-l|--lines]}} {{1000}} - {{path/to/output}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
stat
stat [OPTION]... FILE...
Display file or file system status.
Options
--dereference,-L-
follow links
--file-system,-f-
display file system status instead of file status
--terse,-t-
print the information in terse form
--format=<FORMAT>,-c <FORMAT>-
use the specified FORMAT instead of the default;
output a newline after each use of FORMAT --printf=<FORMAT>-
like –format, but interpret backslash escapes,
and do not output a mandatory trailing newline;
if you want a newline, include \n in FORMAT
Valid format sequences for files (without --file-system):
-%a: access rights in octal (note ‘#’ and ‘0’ printf flags)
-%A: access rights in human readable form
-%b: number of blocks allocated (see %B)
-%B: the size in bytes of each block reported by %b
-%C: SELinux security context string
-%d: device number in decimal
-%D: device number in hex
-%f: raw mode in hex
-%F: file type
-%g: group ID of owner
-%G: group name of owner
-%h: number of hard links
-%i: inode number
-%m: mount point
-%n: file name
-%N: quoted file name with dereference (follow) if symbolic link
-%o: optimal I/O transfer size hint
-%s: total size, in bytes
-%t: major device type in hex, for character/block device special files
-%T: minor device type in hex, for character/block device special files
-%u: user ID of owner
-%U: user name of owner
-%w: time of file birth, human-readable; - if unknown
-%W: time of file birth, seconds since Epoch; 0 if unknown
-%x: time of last access, human-readable
-%X: time of last access, seconds since Epoch
-%y: time of last data modification, human-readable
-%Y: time of last data modification, seconds since Epoch
-%z: time of last status change, human-readable
-%Z: time of last status change, seconds since Epoch
Valid format sequences for file systems:
-%a: free blocks available to non-superuser
-%b: total data blocks in file system
-%c: total file nodes in file system
-%d: free file nodes in file system
-%f: free blocks in file system
-%i: file system ID in hex
-%l: maximum length of filenames
-%n: file name
-%s: block size (for faster transfers)
-%S: fundamental block size (for block counts)
-%t: file system type in hex
-%T: file system type in human readable form
NOTE: your shell may have its own version of stat, which usually supersedes the version described here. Please refer to your shell’s documentation for details about the options it supports.
Examples
Display properties about a specific file such as size, permissions, creation date, and access date among others:
stat {{path/to/file}}
Display properties about a specific file, only showing the raw result data without labels:
stat {{[-t|--terse]}} {{path/to/file}}
Display information about the filesystem where a specific file is located:
stat {{[-f|--file-system]}} {{path/to/file}}
Show only octal file permissions:
stat {{[-c|--format]}} "%a %n" {{path/to/file}}
Show the owner and group of a specific file:
stat {{[-c|--format]}} "%U %G" {{path/to/file}}
Show the size of a specific file in bytes:
stat {{[-c|--format]}} "%s %n" {{path/to/file}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
stdbuf
stdbuf [OPTION]... COMMAND
Run COMMAND, with modified buffering operations for its standard streams.
Mandatory arguments to long options are mandatory for short options too.
Options
--input=<MODE>,-i <MODE>-
adjust standard input stream buffering
--output=<MODE>,-o <MODE>-
adjust standard output stream buffering
--error=<MODE>,-e <MODE>-
adjust standard error stream buffering
If MODE is ‘L’ the corresponding stream will be line buffered. This option is invalid with standard input.
If MODE is ‘0’ the corresponding stream will be unbuffered.
Otherwise, MODE is a number which may be followed by one of the following:
KB 1000, K 1024, MB 10001000, M 10241024, and so on for G, T, P, E, Z, Y. In this case the corresponding stream will be fully buffered with the buffer size set to MODE bytes.
NOTE: If COMMAND adjusts the buffering of its standard streams (tee does for e.g.) then that will override corresponding settings changed by stdbuf. Also some filters (like dd and cat etc.) don’t use streams for I/O, and are thus unaffected by stdbuf settings.
Examples
Change stdin buffer size to 512 KiB:
stdbuf {{[-i|--input]}} 512K {{command}}
Change stdout buffer to line-buffered:
stdbuf {{[-o|--output]}} L {{command}}
Change stderr buffer to unbuffered:
stdbuf {{[-e|--error]}} 0 {{command}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
stty
stty [-F DEVICE | --file=DEVICE] [SETTING]...
or: stty [-F DEVICE | --file=DEVICE] [-a|--all]
or: stty [-F DEVICE | --file=DEVICE] [-g|--save]
Print or change terminal characteristics.
Options
--all,-a-
stty-option-all
--save,-g-
stty-option-save
--file=<DEVICE>,-F <DEVICE>-
stty-option-file
-
stty-option-settings
Examples
Display current terminal size:
stty size
Display all settings for the current terminal:
stty {{[-a|--all]}}
Set the number of rows or columns:
stty {{rows|cols}} {{count}}
Get the actual transfer speed of a device:
stty {{[-F|--file]}} {{path/to/device_file}} speed
Reset all modes to reasonable values for the current terminal:
stty sane
Switch between raw and normal mode:
stty {{raw|cooked}}
Turn character echoing off or on:
stty {{-echo|echo}}
Display help:
stty --help
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
sum
sum [OPTION]... [FILE]...
Checksum and count the blocks in a file.
With no FILE, or when FILE is -, read standard input.
Options
-r-
use the BSD sum algorithm, use 1K blocks (default)
--sysv,-s-
use System V sum algorithm, use 512 bytes blocks
Examples
Compute a checksum with BSD-compatible algorithm and 1024-byte blocks:
sum {{path/to/file}}
Compute a checksum with System V-compatible algorithm and 512-byte blocks:
sum {{[-s|--sysv]}} {{path/to/file}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
sync
sync [OPTION]... FILE...
Synchronize cached writes to persistent storage
Options
--file-system,-f-
sync the file systems that contain the files (Linux and Windows only)
--data,-d-
sync only file data, no unneeded metadata (Linux only)
Examples
Flush all pending write operations on all disks:
sync
Flush all pending write operations on a single file to disk:
sync {{path/to/file}}
Flush writes and drop filesystem caches (Linux only):
sync; echo 3 | sudo tee /proc/sys/vm/drop_caches
Flush disk writes and attempts to clear inactive memory and filesystem caches (macOS only):
sync; sudo purge
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
tac
tac [OPTION]... [FILE]...
Write each file to standard output, last line first.
Options
--before,-b-
attach the separator before instead of after
--regex,-r-
interpret the sequence as a regular expression
--separator=<STRING>,-s <STRING>-
use STRING as the separator instead of newline
Examples
Concatenate specific files in reversed order:
tac {{path/to/file1 path/to/file2 ...}}
Display stdin in reversed order:
{{cat path/to/file}} | tac
Use a specific separator:
tac {{[-s|--separator]}} {{separator}} {{path/to/file1 path/to/file2 ...}}
Use a specific regex as a separator:
tac {{[-r|--regex]}} {{[-s|--separator]}} {{separator}} {{path/to/file1 path/to/file2 ...}}
Use a separator before each file:
tac {{[-b|--before]}} {{path/to/file1 path/to/file2 ...}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
tail
tail [FLAG]... [FILE]...
Print the last 10 lines of each FILE to standard output. With more than one FILE, precede each with a header giving the file name. With no FILE, or when FILE is -, read standard input. Mandatory arguments to long flags are mandatory for short flags too.
Options
--bytes,-c-
Number of bytes to print
--follow,-f-
Print the file as it grows
--lines,-n-
Number of lines to print
--pid=<PID>-
With -f, terminate after process ID, PID dies
--quiet,--silent,-q-
Never output headers giving file names
--sleep-interval=<N>,-s <N>-
Number of seconds to sleep between polling the file when running with -f
--max-unchanged-stats=<N>-
Reopen a FILE which has not changed size after N (default 5) iterations to see if it has been unlinked or renamed (this is the usual case of rotated log files); This option is meaningful only when polling (i.e., with –use-polling) and when –follow=name
--verbose,-v-
Always output headers giving file names
--zero-terminated,-z-
Line delimiter is NUL, not newline
--use-polling-
Disable ‘inotify’ support and use polling instead
--retry-
Keep trying to open a file if it is inaccessible
-F-
Same as –follow=name –retry
--debug-
indicate which –follow implementation is used
--presume-input-pipe
Examples
Show last 10 lines in a file:
tail {{path/to/file}}
Show last 10 lines of multiple files:
tail {{path/to/file1 path/to/file2 ...}}
Show last 5 lines in file:
tail {{[-5|--lines 5]}} {{path/to/file}}
Print a file from a specific line number:
tail {{[-n|--lines]}} +{{count}} {{path/to/file}}
Print a specific count of bytes from the end of a given file:
tail {{[-c|--bytes]}} {{count}} {{path/to/file}}
Print the last lines of a given file and keep reading it until <Ctrl c>:
tail {{[-f|--follow]}} {{path/to/file}}
Keep reading file until <Ctrl c>, even if the file is inaccessible:
tail {{[-F|--retry --follow]}} {{path/to/file}}
Show last count lines in a file and refresh every seconds seconds:
tail {{[-n|--lines]}} {{count}} {{[-s|--sleep-interval]}} {{seconds}} {{[-f|--follow]}} {{path/to/file}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
tee
tee [OPTION]... [FILE]...
Copy standard input to each FILE, and also to standard output.
Options
--help,-h-
Print help
--append,-a-
append to the given FILEs, do not overwrite
--ignore-interrupts,-i-
ignore interrupt signals (ignored on non-Unix platforms)
-p-
set write error behavior (ignored on non-Unix platforms)
--output-error-
set write error behavior
If a FILE is -, it refers to a file named - .
Examples
Copy stdin to each file, and also to stdout:
echo "example" | tee {{path/to/file}}
Append to the given files, do not overwrite:
echo "example" | tee {{[-a|--append]}} {{path/to/file}}
Print stdin to the terminal, and also pipe it into another program for further processing:
echo "example" | tee {{/dev/tty}} | {{xargs printf "[%s]"}}
Create a directory called “example”, count the number of characters in “example”, and write “example” to the terminal:
echo "example" | tee >(xargs mkdir) >(wc {{[-c|--bytes]}})
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
test
test EXPRESSION
test
[ EXPRESSION ]
[ ]
[ OPTION
Check file types and compare values.
Options
Exit with the status determined by EXPRESSION.
An omitted EXPRESSION defaults to false. Otherwise, EXPRESSION is true or false and sets exit status. It is one of:
( EXPRESSION ) EXPRESSION is true
! EXPRESSION EXPRESSION is false
EXPRESSION1 -a EXPRESSION2 both EXPRESSION1 and EXPRESSION2 are true
EXPRESSION1 -o EXPRESSION2 either EXPRESSION1 or EXPRESSION2 is true
String operations:
-n STRING the length of STRING is nonzero
STRING equivalent to -n STRING
-z STRING the length of STRING is zero
STRING1 = STRING2 the strings are equal
STRING1 != STRING2 the strings are not equal
STRING1 > STRING2 STRING1 is greater than STRING2 in the current locale
STRING1 < STRING2 STRING1 is less than STRING2 in the current locale
Integer comparisons:
INTEGER1 -eq INTEGER2 INTEGER1 is equal to INTEGER2
INTEGER1 -ge INTEGER2 INTEGER1 is greater than or equal to INTEGER2
INTEGER1 -gt INTEGER2 INTEGER1 is greater than INTEGER2
INTEGER1 -le INTEGER2 INTEGER1 is less than or equal to INTEGER2
INTEGER1 -lt INTEGER2 INTEGER1 is less than INTEGER2
INTEGER1 -ne INTEGER2 INTEGER1 is not equal to INTEGER2
File operations:
FILE1 -ef FILE2 FILE1 and FILE2 have the same device and inode numbers
FILE1 -nt FILE2 FILE1 is newer (modification date) than FILE2
FILE1 -ot FILE2 FILE1 is older than FILE2
-b FILE FILE exists and is block special
-c FILE FILE exists and is character special
-d FILE FILE exists and is a directory
-e FILE FILE exists
-f FILE FILE exists and is a regular file
-g FILE FILE exists and is set-group-ID
-G FILE FILE exists and is owned by the effective group ID
-h FILE FILE exists and is a symbolic link (same as -L)
-k FILE FILE exists and has its sticky bit set
-L FILE FILE exists and is a symbolic link (same as -h)
-N FILE FILE exists and has been modified since it was last read
-O FILE FILE exists and is owned by the effective user ID
-p FILE FILE exists and is a named pipe
-r FILE FILE exists and read permission is granted
-s FILE FILE exists and has a size greater than zero
-S FILE FILE exists and is a socket
-t FD file descriptor FD is opened on a terminal
-u FILE FILE exists and its set-user-ID bit is set
-w FILE FILE exists and write permission is granted
-x FILE FILE exists and execute (or search) permission is granted
Except for -h and -L, all FILE-related tests dereference (follow) symbolic links. Beware that parentheses need to be escaped (e.g., by backslashes) for shells. INTEGER may also be -l STRING, which evaluates to the length of STRING.
NOTE: Binary -a and -o are inherently ambiguous. Use test EXPR1 && test EXPR2 or test EXPR1 || test EXPR2 instead.
NOTE: [ honors the –help and –version options, but test does not. test treats each of those as it treats any other nonempty STRING.
NOTE: your shell may have its own version of test and/or [, which usually supersedes the version described here. Please refer to your shell’s documentation for details about the options it supports.
Examples
Test if a given variable is equal to a given string:
test "{{$MY_VAR}}" = "{{/bin/zsh}}"
Test if a given variable is empty ([z]ero length):
test -z "{{$GIT_BRANCH}}"
Test if a [f]ile exists:
test -f "{{path/to/file_or_directory}}"
Test if a [d]irectory does not exist:
test ! -d "{{path/to/directory}}"
If A is true, then do B, or C in the case of an error (notice that C may run even if A fails):
test {{condition}} && {{echo "true"}} || {{echo "false"}}
Use test in a conditional statement:
if test -f "{{path/to/file}}"; then echo "File exists"; else echo "File does not exist"; fi
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
timeout
timeout [OPTION] DURATION COMMAND...
Start COMMAND, and kill it if still running after DURATION.
Options
--foreground,-f-
when not running timeout directly from a shell prompt, allow COMMAND to read from the TTY and get TTY signals; in this mode, children of COMMAND will not be timed out
--kill-after,-k-
also send a KILL signal if COMMAND is still running this long after the initial signal was sent
--preserve-status,-p-
exit with the same status as COMMAND, even when the command times out
--signal=<SIGNAL>,-s <SIGNAL>-
specify the signal to be sent on timeout; SIGNAL may be a name like ‘HUP’ or a number; see ‘kill -l’ for a list of signals
--verbose,-v-
diagnose to stderr any signal sent upon timeout
-
a floating point number with an optional suffix: ‘s’ for seconds (the default), ‘m’ for minutes, ‘h’ for hours or ‘d’ for days ; a duration of 0 disables the associated timeout
-
a command to execute with optional arguments
Upon timeout, send the TERM signal to COMMAND, if no other SIGNAL specified. The TERM signal kills any process that does not block or catch that signal. It may be necessary to use the KILL signal, since this signal can’t be caught.
Exit status: 124 if COMMAND times out, and –preserve-status is not specified 125 if the timeout command itself fails 126 if COMMAND is found but cannot be invoked 127 if COMMAND cannot be found 137 if COMMAND (or timeout itself) is sent the KILL (9) signal (128+9)
- the exit status of COMMAND otherwise
Examples
Run sleep 10 and terminate it after 3 seconds:
timeout 3s sleep 10
Send a signal to the command after the time limit expires (TERM by default, kill -l to list all signals):
timeout {{[-s|--signal]}} {{INT|HUP|KILL|...}} {{5s}} {{sleep 10}}
Send verbose output to stderr showing signal sent upon timeout:
timeout {{[-v|--verbose]}} {{0.5s|1m|1h|1d|...}} {{command}}
Preserve the exit status of the command regardless of timing out:
timeout {{[-p|--preserve-status]}} {{1s|1m|1h|1d|...}} {{command}}
Send a forceful KILL signal after certain duration if the command ignores initial signal upon timeout:
timeout {{[-k|--kill-after]}} {{5m}} {{30s}} {{command}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
touch
touch [OPTION]... [FILE]...
Update the access and modification times of each FILE to the current time.
Options
--help-
Print help information.
-a-
change only the access time
-t <STAMP>-
use [[CC]YY]MMDDhhmm[.ss] instead of the current time
--date=<STRING>,-d <STRING>-
parse argument and use it instead of current time
-f-
(ignored)
-m-
change only the modification time
--no-create,-c-
do not create any files
--no-dereference,-h-
affect each symbolic link instead of any referenced file (only for systems that can change the timestamps of a symlink)
--reference=<FILE>,-r <FILE>-
use this file’s times instead of the current time
--time=<WORD>-
change only the specified time: “access”, “atime”, or “use” are equivalent to -a; “modify” or “mtime” are equivalent to -m
Examples
Create specific files:
touch {{path/to/file1 path/to/file2 ...}}
Set the file [a]ccess or [m]odification times to the current one and don’t create file if it doesn’t exist:
touch {{[-c|--no-create]}} {{-a|-m}} {{path/to/file1 path/to/file2 ...}}
Set the file [t]ime to a specific value and don’t create file if it doesn’t exist:
touch {{[-c|--no-create]}} -t {{YYYYMMDDHHMM.SS}} {{path/to/file1 path/to/file2 ...}}
Set the files’ timestamp to the reference file’s timestamp, and do not create the file if it does not exist:
touch {{[-c|--no-create]}} {{[-r|--reference]}} {{path/to/reference_file}} {{path/to/file1 path/to/file2 ...}}
Set the timestamp by parsing a string:
touch {{[-d|--date]}} "{{last year|5 hours|next thursday|nov 14|...}}" {{path/to/file}}
Create multiple files with an increasing number:
touch {{path/to/file{1..10}}}
Create multiple files with a letter range:
touch {{path/to/file{a..z}}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
tr
tr [OPTION]... SET1 [SET2]
Translate or delete characters
Options
--complement,-c,-C-
use the complement of SET1
--delete,-d-
delete characters in SET1, do not translate
--squeeze-repeats,-s-
replace each sequence of a repeated character that is listed in the last specified SET, with a single occurrence of that character
--truncate-set1,-t-
first truncate SET1 to length of SET2
Translate, squeeze, and/or delete characters from standard input, writing to standard output.
Examples
Replace all occurrences of a character in a file, and print the result:
tr < {{path/to/file}} {{find_character}} {{replace_character}}
Replace all occurrences of a character from another command’s output:
echo {{text}} | tr {{find_character}} {{replace_character}}
Map each character of the first set to the corresponding character of the second set:
tr < {{path/to/file}} '{{abcd}}' '{{jkmn}}'
Delete all occurrences of the specified set of characters from the input:
tr < {{path/to/file}} {{[-d|--delete]}} '{{input_characters}}'
Compress a series of identical characters to a single character:
tr < {{path/to/file}} {{[-s|--squeeze-repeats]}} '{{input_characters}}'
Translate the contents of a file to upper-case:
tr < {{path/to/file}} "[:lower:]" "[:upper:]"
Strip out non-printable characters from a file:
tr < {{path/to/file}} {{[-cd|--complement --delete]}} "[:print:]"
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
true
Immediately returns with the exit status 0, except when invoked with one of the recognized options. In those cases it will try to write the help or version text. Any IO error during this operation causes the program to return 1 instead.
Options
--help-
Print help information
--version-
true-version-text
Examples
Return a successful exit code:
true
Make a command always exit with 0:
{{command}} || true
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
truncate
truncate [OPTION]... [FILE]...
Shrink or extend the size of each file to the specified size.
Options
--io-blocks,-o-
treat SIZE as the number of I/O blocks of the file rather than bytes (NOT IMPLEMENTED)
--no-create,-c-
do not create files that do not exist
--reference=<RFILE>,-r <RFILE>-
base the size of each file on the size of RFILE
--size=<SIZE>,-s <SIZE>-
set or adjust the size of each file according to SIZE, which is in bytes unless –io-blocks is specified
SIZE is an integer with an optional prefix and optional unit. The available units (K, M, G, T, P, E, Z, and Y) use the following format: ‘KB’ => 1000 (kilobytes) ‘K’ => 1024 (kibibytes) ‘MB’ => 10001000 (megabytes) ‘M’ => 10241024 (mebibytes) ‘GB’ => 100010001000 (gigabytes) ‘G’ => 102410241024 (gibibytes) SIZE may also be prefixed by one of the following to adjust the size of each file based on its current size: ‘+’ => extend by ‘-’ => reduce by ‘<’ => at most ‘>’ => at least ‘/’ => round down to multiple of ‘%’ => round up to multiple of
Examples
Set a size of 10 GB to an existing file, or create a new file with the specified size:
truncate {{[-s|--size]}} 10G {{path/to/file}}
Extend the file size by 50 MiB, fill with holes (which reads as zero bytes):
truncate {{[-s|--size]}} +50M {{path/to/file}}
Shrink the file by 2 GiB, by removing data from the end of file:
truncate {{[-s|--size]}} -2G {{path/to/file}}
Empty the file’s content:
truncate {{[-s|--size]}} 0 {{path/to/file}}
Empty the file’s content, but do not create the file if it does not exist:
truncate {{[-s|--size]}} 0 {{[-c|--no-create]}} {{path/to/file}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
tsort
tsort [OPTIONS] FILE
Topological sort the strings in FILE. Strings are defined as any sequence of tokens separated by whitespace (tab, space, or newline), ordering them based on dependencies in a directed acyclic graph (DAG). Useful for scheduling and determining execution order. If FILE is not passed in, stdin is used instead.
Options
-w
Examples
Perform a topological sort consistent with a partial sort per line of input separated by blanks:
tsort {{path/to/file}}
Perform a topological sort consistent on strings:
echo -e "{{UI Backend\nBackend Database\nDocs UI}}" | tsort
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
tty
tty [OPTION]...
Print the file name of the terminal connected to standard input.
Options
--silent,--quiet,-s-
print nothing, only return an exit status
Examples
Print the file name of this terminal:
tty
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
uname
uname [OPTION]...
Print certain system information. With no OPTION, same as -s.
Options
--all,-a-
Behave as though all of the options -mnrsvo were specified.
--kernel-name,-s-
print the kernel name.
--nodename,-n-
print the nodename (the nodename may be a name that the system is known by to a communications network).
--kernel-release,-r-
print the operating system release.
--kernel-version,-v-
print the operating system version.
--machine,-m-
print the machine hardware name.
--operating-system,-o-
print the operating system name.
--processor,-p-
print the processor type (non-portable)
--hardware-platform,-i-
print the hardware platform (non-portable)
Examples
Print kernel name:
uname
Print all available system information:
uname {{[-a|--all]}}
Print system architecture and processor information:
uname {{[-mp|--machine --processor]}}
Print kernel name, kernel release, and kernel version:
uname {{[-srv|--kernel-name --kernel-release --kernel-version]}}
Print system hostname:
uname {{[-n|--nodename]}}
Print the current operating system name:
uname {{[-o|--operating-system]}}
Display help:
uname --help
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
unexpand
unexpand [OPTION]... [FILE]...
Convert blanks in each FILE to tabs, writing to standard output. With no FILE, or when FILE is -, read standard input.
Options
--all,-a-
convert all blanks, instead of just initial blanks
--first-only,-f-
convert only leading sequences of blanks (overrides -a)
--tabs=<N, LIST>,-t <N, LIST>-
use comma separated LIST of tab positions or have tabs N characters apart instead of 8 (enables -a)
--no-utf8,-U-
interpret input file as 8-bit ASCII rather than UTF-8
Examples
Convert blanks in each file to tabs, writing to stdout:
unexpand {{path/to/file}}
Convert blanks to tabs, reading from stdout:
unexpand
Convert all blanks, instead of just initial blanks:
unexpand {{[-a|--all]}} {{path/to/file}}
Convert only leading sequences of blanks (overrides -a):
unexpand --first-only {{path/to/file}}
Have tabs a certain number of characters apart, not 8 (enables -a):
unexpand {{[-t|--tabs]}} {{number}} {{path/to/file}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
uniq
uniq [OPTION]... [INPUT [OUTPUT]]
Report or omit repeated lines.
Options
--all-repeated=<delimit-method>,-D <delimit-method>-
print all duplicate lines. Delimiting is done with blank lines. [default: none]
--group=<group-method>-
show all items, separating groups with an empty line. [default: separate]
--check-chars=<N>,-w <N>-
compare no more than N characters in lines
--count,-c-
prefix lines by the number of occurrences
--ignore-case,-i-
ignore differences in case when comparing
--repeated,-d-
only print duplicate lines
--skip-chars=<N>,-s <N>-
avoid comparing the first N characters
--skip-fields=<N>,-f <N>-
avoid comparing the first N fields
--unique,-u-
only print unique lines
--zero-terminated,-z-
end lines with 0 byte, not newline
Filter adjacent matching lines from INPUT (or standard input), writing to OUTPUT (or standard output).
Note: uniq does not detect repeated lines unless they are adjacent. You may want to sort the input first, or use sort -u without uniq.
Examples
Display each line once:
sort {{path/to/file}} | uniq
Display only unique lines:
sort {{path/to/file}} | uniq {{[-u|--unique]}}
Display only duplicate lines:
sort {{path/to/file}} | uniq {{[-d|--repeated]}}
Display number of occurrences of each line along with that line:
sort {{path/to/file}} | uniq {{[-c|--count]}}
Display number of occurrences of each line, sorted by the most frequent:
sort {{path/to/file}} | uniq {{[-c|--count]}} | sort {{[-nr|--numeric-sort --reverse]}}
Compare only the first 10 characters on each line for uniqueness:
sort {{path/to/file}} | uniq {{[-w|--check-chars]}} 10
Compare text after the first 5 characters on each line for uniqueness:
sort {{path/to/file}} | uniq {{[-s|--skip-chars]}} 5
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
unlink
unlink FILE
unlink OPTION
Unlink the file at FILE.
Options
Examples
Remove the specified file if it is the last link:
unlink {{path/to/file}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
uptime
uptime [OPTION]...
Display the current time, the length of time the system has been up, the number of users on the system, and the average number of jobs in the run queue over the last 1, 5 and 15 minutes.
Options
--since,-s-
system up since
-
file to search boot time from
--pretty,-p-
show uptime in pretty format
Examples
Print current time, uptime, number of logged-in users, and other information:
uptime
Show only the amount of time the system has been booted for:
uptime {{[-p|--pretty]}}
Print the date and time the system booted up at:
uptime {{[-s|--since]}}
Display the time data in seconds:
uptime {{[-r|--raw]}}
Display version:
uptime {{[-V|--version]}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
users
users [FILE]
Print the user names of users currently logged in to the current host.
Options
Examples
Print logged in usernames:
users
Print logged in usernames according to a given file:
users {{/var/log/wmtp}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
vdir
Options
--help-
ls-help-print-help
--format-
ls-help-set-display-format
-C-
ls-help-display-files-columns
--long,-l-
ls-help-display-detailed-info
-x-
ls-help-list-entries-rows
--tabsize=<COLS>,-T <COLS>-
ls-help-assume-tab-stops
-m-
ls-help-list-entries-commas
--zero-
ls-help-list-entries-nul
--dired,-D-
ls-help-generate-dired-output
--hyperlink=<WHEN>-
ls-help-hyperlink-filenames
-1-
ls-help-list-one-file-per-line
-o-
ls-help-long-format-no-group
-g-
ls-help-long-no-owner
--numeric-uid-gid,-n-
ls-help-long-numeric-uid-gid
--quoting-style-
ls-help-set-quoting-style
--literal,-N-
ls-help-literal-quoting-style
--escape,-b-
ls-help-escape-quoting-style
--quote-name,-Q-
ls-help-c-quoting-style
--hide-control-chars,-q-
ls-help-replace-control-chars
--show-control-chars-
ls-help-show-control-chars
--time=<field>-
ls-help-show-time-field
-c-
ls-help-time-change
-u-
ls-help-time-access
--hide=<PATTERN>-
ls-help-hide-pattern
--ignore=<PATTERN>,-I <PATTERN>-
ls-help-ignore-pattern
--ignore-backups,-B-
ls-help-ignore-backups
--sort=<field>-
ls-help-sort-by-field
-S-
ls-help-sort-by-size
-t-
ls-help-sort-by-time
-v-
ls-help-sort-by-version
-X-
ls-help-sort-by-extension
-U-
ls-help-sort-none
--dereference,-L-
ls-help-dereference-all
--dereference-command-line-symlink-to-dir-
ls-help-dereference-dir-args
--dereference-command-line,-H-
ls-help-dereference-args
--no-group,-G-
ls-help-no-group
--author-
ls-help-author
--all,-a-
ls-help-all-files
--almost-all,-A-
ls-help-almost-all
-f-
ls-help-unsorted-all
--directory,-d-
ls-help-directory
--human-readable,-h-
ls-help-human-readable
--kibibytes,-k-
ls-help-kibibytes
--si-
ls-help-si
--block-size=<BLOCK_SIZE>-
ls-help-block-size
--inode,-i-
ls-help-print-inode
--reverse,-r-
ls-help-reverse-sort
--recursive,-R-
ls-help-recursive
--width=<COLS>,-w <COLS>-
ls-help-terminal-width
--size,-s-
ls-help-allocation-size
--color-
ls-help-color-output
--indicator-style-
ls-help-indicator-style
--classify=<when>,-F <when>-
ls-help-classify
--file-type-
ls-help-file-type
-p-
ls-help-slash-directories
--time-style=<TIME_STYLE>-
ls-help-time-style
--full-time-
ls-help-full-time
--context,-Z-
ls-help-context
--group-directories-first-
ls-help-group-directories-first
Examples
View documentation for the original command:
tldr ls
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
wc
wc [OPTION]... [FILE]...
Print newline, word, and byte counts for each FILE, and a total line if more than one FILE is specified.
Options
--bytes,-c-
print the byte counts
--chars,-m-
print the character counts
--files0-from=<F>-
read input from the files specified by
NUL-terminated names in file F;
If F is - then read names from standard input --lines,-l-
print the newline counts
--max-line-length,-L-
print the length of the longest line
--total=<WHEN>-
when to print a line with total counts;
WHEN can be: auto, always, only, never --words,-w-
print the word counts
--debug
Examples
Count all lines in a file:
wc {{[-l|--lines]}} {{path/to/file}}
Count all words in a file:
wc {{[-w|--words]}} {{path/to/file}}
Count all bytes in a file:
wc {{[-c|--bytes]}} {{path/to/file}}
Count all characters in a file (taking multi-byte characters into account):
wc {{[-m|--chars]}} {{path/to/file}}
Count all lines, words, and bytes from stdin:
{{find .}} | wc
Count the length of the longest line in number of characters:
wc {{[-L|--max-line-length]}} {{path/to/file}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
who
who [OPTION]... [ FILE | ARG1 ARG2 ]
Print information about users who are currently logged in.
Options
--all,-a-
same as -b -d –login -p -r -t -T -u
--boot,-b-
time of last system boot
--dead,-d-
print dead processes
--heading,-H-
print line of column headings
--login,-l-
print system login processes
--lookup-
attempt to canonicalize hostnames via DNS
-m-
only hostname and user associated with stdin
--process,-p-
print active processes spawned by init
--count,-q-
all login names and number of users logged on
--runlevel,-r-
print current runlevel
--short,-s-
print only name, line, and time (default)
--time,-t-
print last system clock change
--users,-u-
list users logged in
--mesg,--message,--writable,-T,-w-
add user’s message status as +, - or ?
Examples
Display the username, line, and time of all currently logged-in sessions:
who
Display all available information:
who {{[-a|--all]}}
Display all available information with table headers:
who {{[-aH|--all --heading]}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
whoami
whoami
Print the current username.
Options
Examples
View documentation for the original command:
tldr id
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.
yes
yes [STRING]...
Repeatedly display a line with STRING (or ‘y’)
Options
Examples
Repeatedly output y:
yes
Repeatedly output a specified value:
yes {{value}}
Accept everything prompted by the apt-get command:
yes | sudo apt-get install {{program}}
Repeatedly output a newline to always accept the default option of a prompt:
yes ''
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.