POSIXコマンドチートシート(を作る)

  • 30
    いいね
  • 0
    コメント
この記事は最終更新日から1年以上が経過しています。

この記事の説明

POSIX規格で用意されているコマンドとその概要が一覧できるページ(チートシート)が欲しいという要望をもらった。もちろんThe Open GroupのPOSIXのページへ行って、1つ1つのコマンドのページを開けばわかることはわかるのだが、概要という形では一覧できない。

確かにそうだと思ったので、生成することにした。もちろんPOSIX原理主義(極力POSIXの範囲のコマンド)1で。 そこはやっぱ意地でしょ。

というわけで、まずは生成したチートシートをどうぞ。

これが、POSIXの範囲で使えるコマンド一覧だ!

  • admin - create and administer SCCS files (DEVELOPMENT)
  • alias - define or display aliases
  • ar - create and maintain library archives
  • asa - interpret carriage-control characters
  • at - execute commands at a later time
  • awk - pattern scanning and processing language
  • basename - return non-directory portion of a pathname
  • batch - schedule commands to be executed in a batch queue
  • bc - arbitrary-precision arithmetic language
  • bg - run jobs in the background
  • c99 - compile standard C programs
  • cal - print a calendar
  • cat - concatenate and print files
  • cd - change the working directory
  • cflow - generate a C-language flowgraph (DEVELOPMENT)
  • chgrp - change the file group ownership
  • chmod - change the file modes
  • chown - change the file ownership
  • cksum - write file checksums and sizes
  • cmp - compare two files
  • comm - select or reject lines common to two files
  • command - execute a simple command
  • compress - compress data
  • cp - copy files
  • crontab - schedule periodic background work
  • csplit - split files based on context
  • ctags - create a tags file (DEVELOPMENT, FORTRAN)
  • cut - cut out selected fields of each line of a file
  • cxref - generate a C-language program cross-reference table (DEVELOPMENT)
  • date - write the date and time
  • dd - convert and copy a file
  • delta - make a delta (change) to an SCCS file (DEVELOPMENT)
  • df - report free disk space
  • diff - compare two files
  • dirname - return the directory portion of a pathname
  • du - estimate file space usage
  • echo - write arguments to standard output
  • ed - edit text
  • env - set the environment for command invocation
  • ex - text editor
  • expand - convert tabs to spaces
  • expr - evaluate arguments as an expression
  • false - return false value
  • fc - process the command history list
  • fg - run jobs in the foreground
  • file - determine file type
  • find - find files
  • fold - filter for folding lines
  • fort77 - FORTRAN compiler (FORTRAN)
  • fuser - list process IDs of all processes that have one or more files open
  • gencat - generate a formatted message catalog
  • get - get a version of an SCCS file (DEVELOPMENT)
  • getconf - get configuration values
  • getopts - parse utility options
  • grep - search a file for a pattern
  • hash - remember or report utility locations
  • head - copy the first part of files
  • iconv - codeset conversion
  • id - return user identity
  • ipcrm - remove an XSI message queue, semaphore set, or shared memory segment identifier
  • ipcs - report XSI interprocess communication facilities status
  • jobs - display status of jobs in the current session
  • join - relational database operator
  • kill - terminate or signal processes
  • lex - generate programs for lexical tasks (DEVELOPMENT)
  • link - call link function
  • ln - link files
  • locale - get locale-specific information
  • localedef - define locale environment
  • logger - log messages
  • logname - return the user's login name
  • lp - send files to a printer
  • ls - list directory contents
  • m4 - macro processor
  • mailx - process messages
  • make - maintain, update, and regenerate groups of programs (DEVELOPMENT)
  • man - display system documentation
  • mesg - permit or deny messages
  • mkdir - make directories
  • mkfifo - make FIFO special files
  • more - display files on a page-by-page basis
  • mv - move files
  • newgrp - change to a new group
  • nice - invoke a utility with an altered nice value
  • nl - line numbering filter
  • nm - write the name list of an object file (DEVELOPMENT)
  • nohup - invoke a utility immune to hangups
  • od - dump files in various formats
  • paste - merge corresponding or subsequent lines of files
  • patch - apply changes to files
  • pathchk - check pathnames
  • pax - portable archive interchange
  • pr - print files
  • printf - write formatted output
  • prs - print an SCCS file (DEVELOPMENT)
  • ps - report process status
  • pwd - return working directory name
  • qalter - alter batch job
  • qdel - delete batch jobs
  • qhold - hold batch jobs
  • qmove - move batch jobs
  • qmsg - send message to batch jobs
  • qrerun - rerun batch jobs
  • qrls - release batch jobs
  • qselect - select batch jobs
  • qsig - signal batch jobs
  • qstat - show status of batch jobs
  • qsub - submit a script
  • read - read a line from standard input
  • renice - set nice values of running processes
  • rm - remove directory entries
  • rmdel - remove a delta from an SCCS file (DEVELOPMENT)
  • rmdir - remove directories
  • sact - print current SCCS file-editing activity (DEVELOPMENT)
  • sccs - front end for the SCCS subsystem (DEVELOPMENT)
  • sed - stream editor
  • sh - shell, the standard command language interpreter
  • sleep - suspend execution for an interval
  • sort - sort, merge, or sequence check text files
  • split - split files into pieces
  • strings - find printable strings in files
  • strip - remove unnecessary information from strippable files (DEVELOPMENT)
  • stty - set the options for a terminal
  • tabs - set terminal tabs
  • tail - copy the last part of a file
  • talk - talk to another user
  • tee - duplicate standard input
  • test - evaluate expression
  • time - time a simple command
  • touch - change file access and modification times
  • tput - change terminal characteristics
  • tr - translate characters
  • true - return true value
  • tsort - topological sort
  • tty - return user's terminal name
  • type - write a description of command type
  • ulimit - set or report file size limit
  • umask - get or set the file mode creation mask
  • unalias - remove alias definitions
  • uname - return system name
  • uncompress - expand compressed data
  • unexpand - convert spaces to tabs
  • unget - undo a previous get of an SCCS file (DEVELOPMENT)
  • uniq - report or filter out repeated lines in a file
  • unlink - call the unlink function
  • uucp - system-to-system copy
  • uudecode - decode a binary file
  • uuencode - encode a binary file
  • uustat - uucp status enquiry and job control
  • uux - remote command execution
  • val - validate SCCS files (DEVELOPMENT)
  • vi - screen-oriented (visual) display editor
  • wait - await process completion
  • wc - word, line, and byte or character count
  • what - identify SCCS files (DEVELOPMENT)
  • who - display who is on the system
  • write - write to another user
  • xargs - construct argument lists and invoke utility
  • yacc - yet another compiler compiler (DEVELOPMENT)
  • zcat - expand and concatenate data

注意(Notice)

このチートシートは、"The Open Gruop"のPOSIXドキュメントサイトに基づき、2015/09/12に生成したものです。
正確を期すため、オリジナルのページを閲覧することを推奨します。
尚、このドキュメントに関する著作権は全て上記の団体に帰属します。

This cheatsheet was generated with the Open Groups POSIX document site on 2015/09/12.
You should refer the original page.
The all copyrights of these documents belong to them.

生成に用いたソースコード

飽くまで自動生成したんだよーという言い訳と、POSIXの実力を示すために使ったソースコードを貼っておく。(ただし、コメントは英語だけね)

mk_posix_cheatsheet_md.sh
#! /bin/sh

######################################################################
#
# MK_POSIX_CHEATSHEET_MD.sh :  Make the Cheat Sheet of POSIX Commands
#
# Usage    : mk_posix_cheatsheet_md.sh [> /PATH/TO/SOME/FILE]
#
# * This command generates the list of the POSIX commands in Markdown
#   with ONLY the POSIX commands except one of HTTP-GET command. And
#   writes that into the standard output.
#
# * I made sure that this script can generate the HTML text correctly
#   from the Open Group POSIX document site on 2015/09/12. But in the
#   future, it also needs to revise the script for scraping the revised
#   POSIX document.
#
# Required : One of HTTP-GET command (wget or curl or fetch)
#
# Written by Rich Mikan (richmikan[at]richlab.org) on 2015/09/12
#
# This is a public-domain software. It measns that all of the people
# can use this with no restrictions at all. By the way, I am fed up
# the side effects which are broght about by the major licenses.
#
######################################################################


# ====================================================================
# configure (SET THIS)
# ====================================================================

BASE='http://pubs.opengroup.org/onlinepubs/9699919799/'
CMDs='idx/utilities.html'


# ====================================================================
# make sure some depend non-POSIX commands (One of HTTP-GET required)
# ====================================================================

if   type wget  >/dev/null 2>&1; then
  CMD='wget -nv -O -'
elif type curl  >/dev/null 2>&1; then
  CMD='curl -s'
elif type fetch >/dev/null 2>&1; then
  CMD='fetch -q -o -'
else
  printf '%s: No HTTP-GET command found.\n' "${0##*/}" 1>&2
  exit 1
fi


# ====================================================================
# print the previous Markdown
# ====================================================================

cat <<PREVIOUS_MD
# POSIX commands Cheatsheat

PREVIOUS_MD


# ====================================================================
# print the command list in Markdown
# ====================================================================

$CMD "${BASE%/}/${CMDs}"                                                     |
sed -n '/a  *href=/{s!.*href="\([^"]*\)".*!'"${BASE%/}/${CMDs%/*}/"'\1!;p;}' |
sed 's![^/]*/\.\./!!'                                                        |
while read url; do                                                           #
  export url                                                                 #
  $CMD "$url"                                             |                  #
  awk 'step==2                   {next  ;              }  #                  #
       step==1 && /blockquote/   {print ; step=2; next;}  #                  #
       /class="mansect".*>NAME</ {step=1; next  ;      }' |                  #
  sed 's!^.*<blockquote>!!'                               |                  #
  sed 's!</blockquote>.*$!!'                              |                  #
  awk 'BEGIN { OFS=""; ORS=""; }                          #                  #
       match($0, /[^ \t]+/) {                             #                  #
         print "* "                                ;      #                  #
         print substr($0, 1             , RSTART-1);      #                  #
         print "["                                 ;      #                  #
         print substr($0, RSTART        , RLENGTH );      #                  #
         print "]"                                 ;      #                  #
         print "(", ENVIRON["url"], ")"            ;      #                  #
         print substr($0, RSTART+RLENGTH          );      #                  #
         print "\n"                                ;      #                  #
       }'                                                                    #
done                                                                         |
sed 's!</\{0,1\}b>!**!g'


# ====================================================================
# print the following Markdown
# ====================================================================

cat <<FOLLOWING_MD

## Notice

This page was generated with the Open Groups POSIX document site on $(date '+%Y/%m/%d').
You should refer the [original page](${BASE}).

The all copyrights of these documents belong to them. 
FOLLOWING_MD


# ====================================================================
# finish normally
# ====================================================================
exit 0

こんなの夜食前だ!(只今午前2時)

さてそれじゃ、豆乳つゆちょい足しペヤングでも作って夜食にするか。


  1. POSIXには通信系コマンドが殆どないので、そのための1コマンドだけは非POSIXコマンド(wgetまたはcurlまたはfetch)に頼るが、その他全てはPOSIXの範囲で作る。