LoginSignup
44

More than 5 years have passed since last update.

【bash】行番号を指定しての行の取得

Last updated at Posted at 2015-02-04

自分用のメモ。
行番号を指定しての行の取得方法。sed、awk、bashの3通り。

sed

out.datの2行目取得
#sed -n 行番号P 対象ファイル
sed -n 2P out.dat

awk

out.datの2行目取得
#awk 'NR==行番号' 対象ファイル
awk 'NR==2' out.dat

bash

out.datの2行目取得
#head -n 行番号 対象ファイル | tail -n 1
head -n 2 out.data | tail -n 1

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
44