Skip to main content
added 31 characters in body
Source Link
ormaaj
  • 754
  • 4
  • 11

For entertainment purposes, here's a lazy find generator in Bash. This example generates a ring over the files in the current directory. Read however many you want then kill %+ (maybe just 1)

#!/usr/bin/env bash unset -v files n trap 'kill "$x_PID"' EXIT  coproc x while :; do find . -type f -maxdepth 1 -exec sh -c "$(</dev/fd/3)" _ {} + done 4<&0 <<\EOF 3<&0 <&4- for x; do read -r _ printf '%s\0' "$x" done EOF while echo >&${x[1]} IFS= read -rd '' -u "$x" 'files[n++]' do printf '%q ' "${files[@]}" echo sleep .2 done 

For entertainment purposes, here's a lazy find generator in Bash. This example generates a ring over the files in the current directory. Read however many you want then kill %+ (maybe just 1)

#!/usr/bin/env bash unset -v files n coproc x while :; do find . -type f -maxdepth 1 -exec sh -c "$(</dev/fd/3)" _ {} + done 4<&0 <<\EOF 3<&0 <&4- for x; do read -r _ printf '%s\0' "$x" done EOF while echo >&${x[1]} IFS= read -rd '' -u "$x" 'files[n++]' do printf '%q ' "${files[@]}" echo sleep .2 done 

For entertainment purposes, here's a lazy find generator in Bash. This example generates a ring over the files in the current directory. Read however many you want then kill %+ (maybe just 1)

#!/usr/bin/env bash unset -v files n trap 'kill "$x_PID"' EXIT  coproc x while :; do find . -type f -maxdepth 1 -exec sh -c "$(</dev/fd/3)" _ {} + done 4<&0 <<\EOF 3<&0 <&4- for x; do read -r _ printf '%s\0' "$x" done EOF while echo >&${x[1]} IFS= read -rd '' -u "$x" 'files[n++]' do printf '%q ' "${files[@]}" echo sleep .2 done 
Source Link
ormaaj
  • 754
  • 4
  • 11

For entertainment purposes, here's a lazy find generator in Bash. This example generates a ring over the files in the current directory. Read however many you want then kill %+ (maybe just 1)

#!/usr/bin/env bash unset -v files n coproc x while :; do find . -type f -maxdepth 1 -exec sh -c "$(</dev/fd/3)" _ {} + done 4<&0 <<\EOF 3<&0 <&4- for x; do read -r _ printf '%s\0' "$x" done EOF while echo >&${x[1]} IFS= read -rd '' -u "$x" 'files[n++]' do printf '%q ' "${files[@]}" echo sleep .2 done