質問

I currently use this as input for a random song selector:

done < <(sort -zuR <(find "$dir" -type f \( -name '*.mp3' -o -name '*.ogg' \) -print0))

but I have noticed often that I get songs from the same album in what I consider to be a rather large music catalogue. Anyways I wanted to try and pipe thru 'shuf' to see if I notice any difference, but I can't seem to get it to work.

I tried what I felt was obvious:

done < <(shuf <(find "$dir" -type f \( -name '*.mp3' -o -name '*.ogg' \) -print0))

and then:

done < <(find "$dir" -type f \( -name '*.mp3' -o -name '*.ogg' \) -print0|shuf)

and this just in case:

done < <(find "$dir" -type f \( -name '*.mp3' -o -name '*.ogg' \)|shuf)

but so far no love.

But when I create an array like this and walk thru the elements with a 'for' loop the pipe to 'shuf' seems to work fine:

trksShuf=($(find "$dir" -type f \( -name '*.mp3' -o -name '*.ogg' \)|shuf)
役に立ちましたか?

解決

You didn't write how your attempts fail for you, but a quick look into the shuf(1) manual suggests using its -z switch to adapt it to the NUL-separated input.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top