
ファイルの1行目を表示 Linuxコマンド head
2020-08-311 min read
目次
概要
headコマンドでファイルの 1行目もしくは指定した行数だけ表示する方法。
head
利用できるオプション
usage: head [-n lines | -c bytes] [file ...]
コマンド例
./path/to/file.txt
の 1行目だけを表示
$ head -n 1 ./path/to/file.txt
./path/to/file.txt
の 5行目までを表示
$ head -n 5 ./path/to/file.txt
カレントディレクトリ以下の全てのtxtファイルの1行目を表示
$ find ./ -type f -name "*.txt" | xargs head -n 1
Recommends
New Posts
Hot posts!
Date
Tags
Author