LoginSignup
2

More than 5 years have passed since last update.

ファイルの行をランダムで抽出するワンライナー

Posted at
perl -MList::Util=shuffle -e 'print shuffle(<>)' < hoge.txt

適当な行数を出力したい場合は tail -n で行数指定する。

perl -MList::Util=shuffle -e 'print shuffle(<>)' < hoge.txt | tail -n 1000 >> fuga.txt

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
2