[英]How to search for a pattern inside a file and delete the lines in Unix on the command line?
[英]how can i shuffle the lines of a file by chunks of 100 lines with Unix command line tools?
我有一个大文本文件,我想通过100行的块来洗牌。 因此,保留了每行100行中的顺序。 有没有办法只用Unix命令行工具来完成这个?
是。 首先split
输入文件split
为名为“foo ...”的100行块。 然后请shuf
来shuf
他们的名字。 然后cat
在一起的结果。
split -l 100 INPUTFILE foo
cat $(/bin/ls foo* | shuf)
您可以通过创建数字1到100的输入文件来简单地测试它,如下所示:
seq 1 100 > inputfile.txt
然后使用5行的块。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.