完成品
こちらが完成品です。
表
no
command
desc_en
desc_ja
001
admin
create and administer SCCS files (DEVELOPMENT)
SCCSファイルの作成と管理(開発)
002
alias
define or display aliases
エイリアスを定義または表示する
003
ar
create and maintain library archives
ライブラリアーカイブの作成と維持
004
asa
interpret carriage-control characters
紙送り制御文字を解釈する
005
at
execute commands at a later time
後でコマンドを実行する
006
awk
pattern scanning and processing language
パターンスキャンおよび処理言語
007
basename
return non-directory portion of a pathname
パス名の非ディレクトリ部分を返します
008
batch
schedule commands to be executed in a batch queue
バッチキューで実行されるコマンドをスケジュールする
009
bc
arbitrary-precision arithmetic language
任意精度の算術言語
010
bg
run jobs in the background
バックグラウンドでジョブを実行する
011
c99
compile standard C programs
標準Cプログラムのコンパイル
012
cal
print a calendar
カレンダーを印刷する
013
cat
concatenate and print files
ファイルを連結して印刷する
014
cd
change the working directory
作業ディレクトリを変更する
015
cflow
generate a C-language flowgraph (DEVELOPMENT)
C言語のフローグラフを生成する(開発)
016
chgrp
change the file group ownership
ファイルグループの所有権を変更する
017
chmod
change the file modes
ファイルモードを変更する
018
chown
change the file ownership
ファイルの所有権を変更する
019
cksum
write file checksums and sizes
ファイルのチェックサムとサイズを書き込む
020
cmp
compare two files
2つのファイルを比較する
021
comm
select or reject lines common to two files
2つのファイルに共通する行を選択または拒否する
022
command
execute a simple command
簡単なコマンドを実行する
023
compress
compress data
データを圧縮する
024
cp
copy files
ファイルをコピーする
025
crontab
schedule periodic background work
定期的なバックグラウンド作業のスケジュール
026
csplit
split files based on context
コンテキストに基づいてファイルを分割する
027
ctags
create a tags file (DEVELOPMENT, FORTRAN)
タグファイルを作成する(DEVELOPMENT、FORTRAN)
028
cut
cut out selected fields of each line of a file
ファイルの各行の選択されたフィールドを切り取る
029
cxref
generate a C-language program cross-reference table (DEVELOPMENT)
C言語プログラム相互参照テーブルを生成する(開発)
030
date
write the date and time
日付と時刻を書く
031
dd
convert and copy a file
ファイルを変換してコピーする
032
delta
make a delta (change) to an SCCS file (DEVELOPMENT)
SCCSファイルにデルタ(変更)を加える(開発)
033
df
report free disk space
空きディスク容量を報告する
034
diff
compare two files
2つのファイルを比較する
035
dirname
return the directory portion of a pathname
パス名のディレクトリ部分を返します
036
du
estimate file space usage
ファイルスペースの使用量を見積もる
037
echo
write arguments to standard output
引数を標準出力に書き込む
038
ed
edit text
テキストを編集
039
env
set the environment for command invocation
コマンド呼び出しの環境を設定する
040
ex
text editor
テキストエディタ
041
expand
convert tabs to spaces
タブをスペースに変換する
042
expr
evaluate arguments as an expression
引数を式として評価します
043
false
return false value
偽の値を返す
044
fc
process the command history list
コマンド履歴リストを処理する
045
fg
run jobs in the foreground
フォアグラウンドでジョブを実行する
046
file
determine file type
ファイルタイプを決定する
047
find
find files
ファイルを見つける
048
fold
filter for folding lines
折り線用フィルター
049
fort77
FORTRAN compiler (FORTRAN)
FORTRANコンパイラー(FORTRAN)
050
fuser
list process IDs of all processes that have one or more files open
1つ以上のファイルが開いているすべてのプロセスのプロセスIDを一覧表示する
051
gencat
generate a formatted message catalog
フォーマットされたメッセージカタログを生成する
052
get
get a version of an SCCS file (DEVELOPMENT)
SCCSファイルのバージョンを取得する(開発)
053
getconf
get configuration values
構成値を取得する
054
getopts
parse utility options
解析ユーティリティのオプション
055
grep
search a file for a pattern
ファイルのパターンを検索する
056
hash
remember or report utility locations
ユーティリティの場所を記憶または報告する
057
head
copy the first part of files
ファイルの最初の部分をコピーします
058
iconv
codeset conversion
コードセット変換
059
id
return user identity
ユーザーIDを返す
060
ipcrm
remove an XSI message queue, semaphore set, or shared memory segment identifier
XSIメッセージキュー、セマフォセット、または共有メモリセグメント識別子を削除する
061
ipcs
report XSI interprocess communication facilities status
XSIプロセス間通信機能の状態を報告する
062
jobs
display status of jobs in the current session
現在のセッションのジョブのステータスを表示する
063
join
relational database operator
リレーショナルデータベースオペレーター
064
kill
terminate or signal processes
プロセスの終了またはシグナル
065
lex
generate programs for lexical tasks (DEVELOPMENT)
字句タスク用のプログラムを生成する(開発)
066
link
call link function
リンク機能を呼び出す
067
ln
link files
リンクファイル
068
locale
get locale-specific information
ロケール固有の情報を取得する
069
localedef
define locale environment
ロケール環境を定義する
070
logger
log messages
ログメッセージ
071
logname
return the user's login name
ユーザーのログイン名を返します
072
lp
send files to a printer
ファイルをプリンターに送信する
073
ls
list directory contents
ディレクトリの内容を一覧表示する
074
m4
macro processor
マクロプロセッサ
075
mailx
process messages
プロセスメッセージ
076
make
maintain, update, and regenerate groups of programs (DEVELOPMENT)
プログラムのグループの維持、更新、および再生成(開発)
077
man
display system documentation
ディスプレイシステムのドキュメント
078
mesg
permit or deny messages
メッセージを許可または拒否する
079
mkdir
make directories
ディレクトリを作る
080
mkfifo
make FIFO special files
FIFO特殊ファイルを作成します
081
more
display files on a page-by-page basis
ページごとにファイルを表示する
082
mv
move files
ファイルを移動する
083
newgrp
change to a new group
新しいグループに変更する
084
nice
invoke a utility with an altered nice value
nice値を変更してユーティリティを呼び出す
085
nl
line numbering filter
行番号フィルター
086
nm
write the name list of an object file (DEVELOPMENT)
オブジェクトファイルの名前リストを作成します(DEVELOPMENT)
087
nohup
invoke a utility immune to hangups
ハングアップの影響を受けないユーティリティを呼び出す
088
od
dump files in various formats
さまざまな形式のダンプファイル
089
paste
merge corresponding or subsequent lines of files
ファイルの対応する行または後続の行をマージします
090
patch
apply changes to files
ファイルに変更を適用する
091
pathchk
check pathnames
パス名を確認する
092
pax
portable archive interchange
ポータブルアーカイブ交換
093
pr
print files
印刷ファイル
094
printf
write formatted output
フォーマットされた出力を書き込む
095
prs
print an SCCS file (DEVELOPMENT)
SCCSファイルを印刷する(開発)
096
ps
report process status
プロセスの状態を報告する
097
pwd
return working directory name
作業ディレクトリ名を返します
098
qalter
alter batch job
バッチジョブを変更する
099
qdel
delete batch jobs
バッチジョブを削除する
100
qhold
hold batch jobs
バッチジョブを保留する
101
qmove
move batch jobs
バッチジョブを移動する
102
qmsg
send message to batch jobs
バッチジョブにメッセージを送信する
103
qrerun
rerun batch jobs
バッチジョブを再実行する
104
qrls
release batch jobs
リリースバッチジョブ
105
qselect
select batch jobs
バッチジョブを選択する
106
qsig
signal batch jobs
シグナルバッチジョブ
107
qstat
show status of batch jobs
バッチジョブのステータスを表示する
108
qsub
submit a script
スクリプトを提出する
109
read
read from standard input into shell variables
標準入力からシェル変数に読み込む
110
renice
set nice values of running processes
実行中のプロセスのnice値を設定します
111
rm
remove directory entries
ディレクトリエントリを削除する
112
rmdel
remove a delta from an SCCS file (DEVELOPMENT)
SCCSファイルからデルタを削除します(開発)
113
rmdir
remove directories
ディレクトリを削除する
114
sact
print current SCCS file-editing activity (DEVELOPMENT)
現在のSCCSファイル編集アクティビティを印刷(開発)
115
sccs
front end for the SCCS subsystem (DEVELOPMENT)
SCCSサブシステムのフロントエンド(開発)
116
sed
stream editor
ストリームエディター
117
sh
shell, the standard command language interpreter
シェル、標準コマンド言語インタープリター
118
sleep
suspend execution for an interval
間隔を置いて実行を一時停止する
119
sort
sort, merge, or sequence check text files
テキストファイルの並べ替え、マージ、またはシーケンスチェック
120
split
split a file into pieces
ファイルを断片に分割する
121
strings
find printable strings in files
ファイル内の印刷可能な文字列を見つける
122
strip
remove unnecessary information from strippable files (DEVELOPMENT)
削除可能なファイルから不要な情報を削除する(開発)
123
stty
set the options for a terminal
端末のオプションを設定する
124
tabs
set terminal tabs
端子タブを設定する
125
tail
copy the last part of a file
ファイルの最後の部分をコピーします
126
talk
talk to another user
別のユーザーと話す
127
tee
duplicate standard input
標準入力を複製
128
test
evaluate expression
式を評価する
129
time
time a simple command
簡単なコマンドを実行する
130
touch
change file access and modification times
ファイルのアクセス時間と変更時間を変更する
131
tput
change terminal characteristics
端末の特性を変更する
132
tr
translate characters
文字を翻訳する
133
true
return true value
真の値を返す
134
tsort
topological sort
トポロジカルソート
135
tty
return user's terminal name
ユーザーの端末名を返す
136
type
write a description of command type
コマンドタイプの説明を書く
137
ulimit
set or report file size limit
ファイルサイズの制限を設定または報告する
138
umask
get or set the file mode creation mask
ファイルモード作成マスクを取得または設定します
139
unalias
remove alias definitions
エイリアス定義を削除する
140
uname
return system name
システム名を返す
141
uncompress
expand compressed data
圧縮データを展開する
142
unexpand
convert spaces to tabs
スペースをタブに変換する
143
unget
undo a previous get of an SCCS file (DEVELOPMENT)
SCCSファイルの以前の取得を取り消します(開発)
144
uniq
report or filter out repeated lines in a file
ファイル内の繰り返し行を報告または除外する
145
unlink
call the unlink function
リンク解除関数を呼び出す
146
uucp
system-to-system copy
システム間コピー
147
uudecode
decode a binary file
バイナリファイルをデコードする
148
uuencode
encode a binary file
バイナリファイルをエンコードする
149
uustat
uucp status enquiry and job control
uucpステータス照会とジョブ制御
150
uux
remote command execution
リモートコマンド実行
151
val
validate SCCS files (DEVELOPMENT)
SCCSファイルの検証(開発)
152
vi
screen-oriented (visual) display editor
画面指向(視覚)ディスプレイエディター
153
wait
await process completion
プロセスの完了を待つ
154
wc
word, line, and byte or character count
単語、行、バイトまたは文字数
155
what
identify SCCS files (DEVELOPMENT)
SCCSファイルの識別(開発)
156
who
display who is on the system
システム上のユーザーを表示します
157
write
write to another user
別のユーザーに書き込む
158
xargs
construct argument lists and invoke utility
引数リストを作成し、ユーティリティを呼び出す
159
yacc
yet another compiler compiler (DEVELOPMENT)
さらに別のコンパイラコンパイラ(開発)
160
zcat
expand and concatenate data
データを展開および連結する
動機
この記事を読んで、POSIXにある全コマンドの説明についてのチートシートをMarkdownのtableで作ることを考えた。
また英語と並べて日本語の説明を機械翻訳に投げた結果も取得したくなった。
やること
- 全コマンドとその説明の取得
- transコマンドで説明を翻訳
- Markdown形式のtableへの変換(nl,commandname,desc_ja,desc_en)
やっていき
実行しながら記事を書いていく
まず数確認
$ curl -s "https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html"|grep -oE ">[^<]+<"|uniq -u|wc -l
160
ほーん、160個あんのか
説明文と行番号ほしいな
$ curl -s "https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html" \
| grep -oE ">[^<]+<" | tr -d "<>" \
| while read i;do
curl -s "https://pubs.opengroup.org/onlinepubs/9699919799/utilities/${i}.html" \
| grep -oEm1 '<blockquote>.*</blockquote>'
done | sed -r 's_<[^>]+>__g' | nl -nln -w3
001 admin - create and administer SCCS files (DEVELOPMENT)
002 alias - define or display aliases
003 ar - create and maintain library archives
004 asa - interpret carriage-control characters
(略)
160 zcat - expand and concatenate data
なるほどなあ
翻訳をしたいな
$ sudo apt install translate-shell
$ echo hello | trans -s en -t ja
hello
/heˈlō,həˈlō/
こんにちは
(Kon'nichiwa)
Definitions of hello
[ English -> 日本語 ]
noun
今日は
hello, good day
hello
こんにちは, もしもし
-b
をつけるといい
$ echo hello world|trans -s en -t ja -b
こんにちは世界
前記のコードに|tee >(sed -r 's_^[^-]+- __'|trans -s en -t ja -b)|tr \\n \\t
追記
@
文字をフィールドセパレータに
$ curl -s "https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html" \
| grep -oE ">[^<]+<" | tr -d "<>" \
| while read i;do
curl -s "https://pubs.opengroup.org/onlinepubs/9699919799/utilities/${i}.html" \
| grep -oEm1 '<blockquote>.*</blockquote>' \
| tee >(sed -r 's_^[^-]+- __' | trans -s en -t ja -b) \
| tr \\n @
done | sed -r 's_<[^>]+>__g' | nl -nrz -w3 | sed -r 's/( {2,})/@/g' > data_posi
いい感じ
MarkdownにしてQiitaに貼り付けて終わり
$ cat << EOS > list.md
|no |command|desc_en|desc_ja|
|---|-------|-------|-------|
$(sed -r 's_(^|@|$)_|_g' data_posix)
EOS
実行!しかしtrans
が途中から結果を返していない
どうやらAPI制限らしいのでsleep $[5+$RANDOM%10]
の待ちを入れる
〜一晩経って書き直す〜
#!/bin/bash
url='https://pubs.opengroup.org/onlinepubs/9699919799'
curl -s "${url}/idx/utilities.html" |
grep -oE '>[^<]+<' |
tr -d '<>' |
while read i ;
do curl -s "${url}/utilities/${i}.html" |
grep -oEm1 '<blockquote>.*</blockquote>' |
sed -r 's/<[^>]+>//g' |
tee >( #
sed -r 's/^[^-]+- //' |
trans -s en -t ja -b #
) |
tr \\n @ ;
sleep $[5+$RANDOM%10] ;
done |
nl -nrz -w3 |
sed -r 's/^([0-9]+)\s+/\1@/g;s/(^[0-9]+@[0-9a-z]+) - /\1@/g' > cmd_posix
# ==================
# make a table by md
# ==================
cat << EOS > list.md
|no |command|desc_en|desc_ja|
|---|-------|-------|-------|
$(sed -r 's_(^|@|$)_|_g' cmd_posix)
EOS
※清書はこちら(Gist)
よし実行! (13~40分かかる)
〜1時間後〜
できた!
おわり
シェル芸は最高