Re: [PATCH v2 0/3] use shuf to choose a random file

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



On Mon, Aug 21, 2023 at 03:37:01PM +0900, Naohiro Aota wrote:
> Currently, we use "ls ... | sort -R | head -n1" (or tail) to choose a
> random file in a directory.It sorts the files with "ls", sort it randomly
> and pick the first line, which wastes the "ls" sort.
> 
> Also, using "sort -R | head -n1" is inefficient. Furthermore, even without
> "head" or "tail", "shuf" is faster than "sort -R".
> 
> This series introduces a new helper _random_file() to choose a file in a
> directory randomly. Also, replace "sort -R" with _random_file() or "shuf".

Please discard this version. The _random_file() helper doesn't have the
base directory prefixed. So, the btrfs/192 didn't work well. I'll revise it
soon.



[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux