LoginSignup
11
10

More than 5 years have passed since last update.

ファイルを開かずに行数を指定して削除する

Last updated at Posted at 2014-06-18

ログをあさったりするときにちょくちょく使うコマンド。
よく忘れるので書いておく。

1.行数カウントする

$ wc -l hoge.log
12221189 hoge.log

2.古い時間帯は必要ないので削除

$ time sed -e "1,11000000d" hoge.log > fuga.log

real    0m4.415s
user    0m2.438s
sys 0m1.973s
$
$ wc -l fuga.log
1221189 fuga.log

はやいね!

11
10
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
11
10