Hi,
I have a text file that is a single column. How do I write code to shuffle it? Thanks!
Sample input:
NANP
DLGAP5
BUB1
C4orf46
BID
Hi,
I have a text file that is a single column. How do I write code to shuffle it? Thanks!
Sample input:
NANP
DLGAP5
BUB1
C4orf46
BID
You could use the shuf command...
I get the following error message when I try to use shuf:
-bash: shuf: command not found
Well, what's your system?
x86_64 GNU/Linux
Great, you've told me what your kernel is. Now, linux what? Ubuntu? Centos? Fedora? RHEL? SuSe? Gentoo? Angstrom? That will tell me what software you actually have.
If you don't have shuf, try sort -R, 'sort on hash of random keys'.
Try if this works
awk 'BEGIN{srand() }
{ lines[++d]=$0 }
END{
while (1){
if (e==d) {break}
random = int(1 + rand() * d)
if ( random in lines ){
print lines[random]
delete lines[random]
++e
}
}
}' file