0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Linux 基本的なコマンド2

Posted at

touch

ファイルのタイムスタンプの変更

touch [オプション] ファイル名

-t ファイルの更新時刻を指定する

タイムスタンプはlsコマンドの-iオプションをつけることで確認可能

head,tail

ファイルの一部の取得

head

ファイルの先頭部分を標準出力をする

head [オプション] ファイル名

-n 行 先頭から指定した行を標準出力する
-n バイト 先頭から指定したバイト分を標準出力する

tail

ファイルの終わり部分を標準出力する

tail [オプション] ファイル名

-n 行 末尾から指定した行を標準出力する
-n バイト 末尾から指定したバイト分を標準出力する

特別なオプション -f
このオプションをすることで、変更をリアルタイムでモニタすることが可能

tail -f ファイル名

sort

テキストファイルの中身をソートする

sort [オプション] ファイル名

-r 逆順でソート
-k n n行目のデータをソート
-n 数値としてソート

uniq

行の重複の消去、同じ内容は出力しない。

uniq ファイル名

tr

文字列の置き換え

tr 文字列1 文字列2

diff 

ファイルの比較、変更の有無を調べる場合の用いられる

diff [オプション] ファイル1 ファイル2

-c context diff形式で差分を出力
-u unified diff形式で差分を出力

context形式は1つ目のファイルの内容と2つ目のファイルの内容を別々に出力
unified形式は1つ目のファイルの内容と2つ目の内容を合わせた状態で出力

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?