man マニュアル Linuxコマンド

manより手軽なマニュアル参照系Linuxコマンド

Linuxコマンドライン言語Bashの環境において、コマンドラインソフトウェアやビルトインのコマンドのマニュアルなどを参照するためのビルトインコマンドman、このmanよりもより手軽で敷居の低い感じのマニュアル参照系Linuxコマンドをいくつか(whatis, apropos, aptitude, tldr, cheat など)紹介します。とりあえずこのコマンドがどういうものなのか教えてくれ系…

Shou Arisaka
3 分で読める
2019年1月29日

Linuxコマンドライン言語Bashの環境において、コマンドラインソフトウェアやビルトインのコマンドのマニュアルなどを参照するためのビルトインコマンドman、このmanよりもより手軽で敷居の低い感じのマニュアル参照系Linuxコマンドをいくつか(whatis, apropos, aptitude, tldr, cheat など)紹介します。

tl;dr. (長すぎ。読むのやめよ。)

とりあえずこのコマンドがどういうものなのか教えてくれ系

whatis

``` $ whatis awk awk (1) - pattern scanning and text processing language ```

apropos

whatisより文献が多い。説明文は変わらない。 ``` $ apropos ^awk$ awk (1) - pattern scanning and text processing language ``` ([翻訳] apropos of ~について; apropos of nothing 唐突だが、 (=BTW?))

aptitude show

ubuntuなどapt環境限定。コマンドというよりパッケージについての説明。多少詳細まで説明されていることが多い。 ``` $ whatis sed sed (1) - stream editor for filtering and transforming text

$ aptitude show sed … Description: The GNU sed stream editor sed reads the specified files or the standard input if no files are specified, makes editing changes according to a list of commands, and writes the results to the standard output. Homepage: http://www.gnu.org/software/sed/

## このコマンドの使用例が見たいんだけど系
<h3><strong>tldr</strong></h3>

npm install -g tldr

$ tldr awk

awk

A versatile programming language for working on files.

  • Print the fifth column (a.k.a. field) in a space-separated file: awk ‘{print $5}’ filename

  • Print the second column of the lines containing “something” in a space-separated file: awk ‘/something/ {print $2}’ filename

  • Print the last column of each line in a file, using a comma (instead of space) as a field separator: awk -F ’,’ ‘{print $NF}’ filename

  • Sum the values in the first column of a file and print the total: awk ‘{s+=$1} END {print s}’ filename

  • Sum the values in the first column and pretty-print the values and then the total: awk ‘{s+=$1; print $1} END {print ”--------”; print s}’ filename

  • Print every third line starting from the first line: awk ‘NR%3==1’ filename

[tldr-pages/tldr: Simplified and community-driven man pages](https://github.com/tldr-pages/tldr)
<h3><strong>cheat</strong></h3>
<code>pip install cheat</code>

$ cheat awk

sum integers from a file or stdin, one integer per line:

printf ‘1\n2\n3\n’ | awk ’{ sum += $1} END {print sum}‘

using specific character as separator to sum integers from a file or stdin

printf ‘1:2:3’ | awk -F ”:” ‘{print $1+$2+$3}‘

print a multiplication table

seq 9 | sed ‘H;g’ | awk -v RS=” ‘{for(i=1;i<=NF;i++)printf(“%dx%d=%d%s”, i, NR, i*NR, i==NR?”\n”:“\t”)}‘

Specify output separator character

printf ‘1 2 3’ | awk ‘BEGIN {OFS=”:”}; {print $1,$2,$3}’

[chrisallenlane/cheat: cheat allows you to create and view interactive cheatsheets on the command-line. It was designed to help remind *nix system administrators of options for commands that they use frequently, but not frequently enough to remember.](https://github.com/chrisallenlane/cheat)
## manをもっと手軽に使うためのtips
とは言ってもmanを捨てきれないという方に。
<h3><strong>fzf</strong></h3>
<code>man awk | fzf</code>

[junegunn/fzf: A command-line fuzzy finder](https://github.com/junegunn/fzf#installation)

![Image](https://yuis.xsrv.jp/images/ss/ShareX_ScreenShot_270e7e5c-f55e-499d-be97-5d45bd5821e2.gif)
<h3><strong>vim</strong></h3>
<code>man awk | vim -</code>
<h3><strong>sublimeText3</strong></h3>
<code>man awk &gt; ~/tmp.txt &amp;&amp; sublime_text ~/tmp.txt</code>
<code>man awk &gt; ~/tmp.txt &amp;&amp; gedit ~/tmp.txt</code>
### less
(2021年追記)
やはりmanプラスlessが最強ですよ。lessならg/Gでドキュメントの最初最後まで飛べたり、"/"で正規表現検索、pageup pagedownキーでパパっとページめくりできます。コマンドラインっぽいコマンドラインの使い方ですが慣れると苦ではないのでおすすめです。

この記事をシェア

Shou Arisaka 2019年1月29日

🔗 リンクをコピー