Sampling without replacement using awk

前端 未结 4 676
孤街浪徒
孤街浪徒 2020-12-11 04:35

I have a lot of text files that look like this:

>ALGKAHOLAGGATACCATAGATGGCACGCCCT
>BLGKAHOLAGGATACCATAGATGGCACGCCCT
>HLGKAHOLAGGATACCATAGATGGCACGCCC         


        
4条回答
  •  旧巷少年郎
    2020-12-11 05:14

    Yes, but I wouldn't. I would use shuf or sort -R (neither POSIX) to randomize the file and then select the first n lines using head.

    If you really want to use awk for this, you would need to use the rand function, as Mark Setchell points out.

提交回复
热议问题