dreamin' blog

うちのブログの 前回の更新 が man の話だったので、更新せざるを得ない。


https://tldr.sh が公式ページです。
GitHubを見てみると、 かなりの数のコマンド が対応しています。
日本語 も結構対応していっていますね。


例えば、 ls をとってみると、、、

$ tldr ls


List directory contents.
More information: <https://www.gnu.org/software/coreutils/ls>.

- List files one per line:
    ls -1

- List all files, including hidden files:
    ls -a

- List all files, with trailing `/` added to directory names:
    ls -F

- Long format list (permissions, ownership, size, and modification date) of all files:
    ls -la

- Long format list with size displayed using human readable units (KiB, MiB, GiB):
    ls -lh

- Long format list sorted by size (descending):
    ls -lS

- Long format list of all files, sorted by modification date (oldest first):
    ls -ltr

ちなみに私は llls -ltr をalias しております。

ちなみに難関コマンドの findxargs の例も貼っておきます。

$ tldr find


Find files or directories under the given directory tree, recursively.
More information: <https://manned.org/find>.

- Find files by extension:
    find root_path -name '*.ext'

- Find files matching multiple path/name patterns:
    find root_path -path '**/path/**/*.ext -or -name '*pattern*'

- Find directories matching a given name, in case-insensitive mode:
    find root_path -type d -iname '*lib*'

- Find files matching a given pattern, excluding specific paths:
    find root_path -name '*.py' -not -path '*/site-packages/*'

- Find files matching a given size range:
    find root_path -size +500k -size -10M

- Run a command for each file (use `{}` within the command to access the filename):
    find root_path -name '*.ext' -exec wc -l {} \;

- Find files modified in the last 7 days and delete them:
    find root_path -mtime -7 -delete

- Find empty (0 byte) files and delete them:
    find root_path -type f -empty -delete
$ tldr xargs


Execute a command with piped arguments coming from another command, a file, etc.
The input is treated as a single block of text and split into separate pieces on spaces, tabs, newlines and end-of-file.

- Run a command using the input data as arguments:
    arguments_source | xargs command

- Run multiple chained commands on the input data:
    arguments_source | xargs sh -c "command1 && command2 | command3"

- Delete all files with a `.backup` extension (`-print0` uses a null character to split file names, and `-0` uses it as delimiter):
    find . -name '*.backup' -print0 | xargs -0 rm -v

- Execute the command once for each input line, replacing any occurrences of the placeholder (here marked as `_`) with the input line:
    arguments_source | xargs -I _ command _ optional_extra_arguments

- Parallel runs of up to `max-procs` processes at a time; the default is 1. If `max-procs` is 0, xargs will run as many processes as possible at a time:
    arguments_source | xargs -P max-procs command


それでも man を読むのは大事 だけどな。