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 1 year has passed since last update.

【Shell】指定した行のみ取得する方法

Posted at

1行目のみ取得する

ファイルの1行目のみ取得するには以下のように実行します。

head -n 1 対象ファイルパス

指定した行のみ取得する

指定した行のみ取得するには以下のようにします。

sed -n 行数p 対象ファイルパス

./sample.txtの5行目を取得する場合には以下のように実行します。

sed -n 5p ./sample.txt
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?