[Shell] cmdline-fu, bropages, cheat でコマンドラインツールの使用例を調べる

man 以外の情報を CLI から取得する。

Contents

Installation

まとめてインストールします。

% gem install cmdline-fu bropages cheat

cmdline-fu

ワンライナーを投稿・共有しているサイト。
cmdline-fu matching で対象を検索できる。

% cmdline-fu matching find
true
   :
# Recursively remove all empty directories
find . -type d -empty -delete
# Find files that have been modified on your system in the past 60 minutes
sudo find / -mmin 60 -type f
# Recursively change permissions on files, leave directories alone.
find ./ -type f -exec chmod 644 {} \;
# Search recursively to find a word or phrase in certain file types, such as C code
find . -name "*.[ch]" -exec grep -i -H "search pharse" {} \;
# find files in a date range
find . -type f -newermt "2010-01-01" ! -newermt "2010-06-01"

bropages

command line のサンプルを表示する。
bro で検索できる。

% bro find
21 entries for find -- submit your own example with "bro add find"
# Executes a command on the files and folders matching a given pattern, in this case, output the last lines of each .foo file in the current folder and subfolders.
find . -name "*.foo" -exec tail {} \;
        bro thanks      to upvote (55)
        bro ...no       to downvote (0)
.........................................................................................................................................................................................................................................................................
# Outputs all the file names/paths that start with the name "Casey".  Searches recursively starting from my current directory (.)
# Throws out any error output by sending it to /dev/null
find . -name "Casey*" 2>/dev/null
        bro thanks 2    to upvote (33)
        bro ...no 2     to downvote (0)
.........................................................................................................................................................................................................................................................................
# Finds all files in and under the current directory that contain 'foo' in their name
find . -iname '*foo*'
        bro thanks 3    to upvote (26)
        bro ...no 3     to downvote (1)
.........................................................................................................................................................................................................................................................................

cheat

チートシートを表示する。
cheat で検索できる。

% cheat find
find:
  To search current directory and sub directories for a specific file:
  $ find . -name "rc.conf" -print
  Same, but case insensitive:
  $ find . -iname "rc.conf" -print
  Search for both mpg & avi:
  $ find . -iname '*.mpg' -o -iname '*.avi'
  Same, but files only:
  $ find . -type f -name "rc.conf" -print