この記事は Linux コマンド 全部オレ Advent Calendar 2017 の15日目の記事です。
time
NAME
time - time a simple command or give resource usage
SYNOPSIS
time [options] command [arguments...]
DESCRIPTION
The time command runs the specified program command with the given arguments. When command finishes, time writes a message to
standard error giving timing statistics about this program run. These statistics consist of (i) the elapsed real time between
invocation and termination, (ii) the user CPU time (the sum of the tms_utime and tms_cutime values in a struct tms as returned
by times(2)), and (iii) the system CPU time (the sum of the tms_stime and tms_cstime values in a struct tms as returned by
times(2)).
Note: some shells (e.g., bash(1)) have a built-in time command that provides less functionality than the command described here.
To access the real command, you may need to specify its pathname (something like /usr/bin/time).
実行したコマンドがどれくらいの時間がかかったか確認するコマンド。
real, user, sys
[sinsengumi ~]$ time sleep 4
real 0m4.002s
user 0m0.001s
sys 0m0.000s
用語 | 英語 | 意味 |
---|---|---|
real | real time | プログラムの呼び出しから終了までにかかった実時間 |
user | user CPU time | プログラムが CPU を使った時間(プログラム自身の処理時間) |
sys | system CPU time | プログラム以外(OS)が CPU を使った時間(プログラムに伴って OS が仕事をした時間) |
touch
NAME
touch - change file timestamps
SYNOPSIS
touch [OPTION]... FILE...
DESCRIPTION
Update the access and modification times of each FILE to the current time.
A FILE argument that does not exist is created empty, unless -c or -h is supplied.
A FILE argument string of - is handled specially and causes touch to change the times of the file associated with standard out‐
put.
よく使いそうな使い方
空ファイルを作成する(もしくはファイルのタイムスタンプを更新する)
[sinsengumi ~]$ ls -l
total 0
[sinsengumi ~]$ touch a.txt
[sinsengumi ~]$ ls -l
total 0
-rw-r--r-- 1 sinsengumi sinsengumi 0 Dec 15 16:36 a.txt
[sinsengumi ~]$ touch a.txt
[sinsengumi ~]$ ls -l
total 0
-rw-r--r-- 1 sinsengumi sinsengumi 0 Dec 15 16:37 a.txt
tree
NAME
tree - list contents of directories in a tree-like format.
SYNOPSIS
tree [-acdfghilnpqrstuvxACDFQNSUX] [-L level [-R]] [-H baseHREF] [-T title] [-o filename] [--nolinks] [-P pattern] [-I pattern]
[--inodes] [--device] [--noreport] [--dirsfirst] [--version] [--help] [--filelimit #] [--si] [--prune] [--du] [--timefmt format]
[directory ...]
DESCRIPTION
Tree is a recursive directory listing program that produces a depth indented listing of files, which is colorized ala dircolors
if the LS_COLORS environment variable is set and output is to tty. With no arguments, tree lists the files in the current
directory. When directory arguments are given, tree lists all the files and/or directories found in the given directories each
in turn. Upon completion of listing all files/directories found, tree returns the total number of files and/or directories
listed.
By default, when a symbolic link is encountered, the path that the symbolic link refers to is printed after the name of the link
in the format:
name -> real-path
If the `-l' option is given and the symbolic link refers to an actual directory, then tree will follow the path of the symbolic
link as if it were a real directory.
ファイル・ディレクトリを木構造で出力する。
よく使いそうな使い方
[sinsengumi nginx]$ tree
.
├── conf.d
│ ├── default.conf
│ └── reverse_proxy.conf
├── fastcgi_params
├── koi-utf
├── koi-win
├── mime.types
├── modules -> ../../usr/lib64/nginx/modules
├── nginx.conf
├── scgi_params
├── uwsgi_params
└── win-utf