How can I figure out if a file descriptor is currently in use in Bash? For example, if I have a script that reads, writes, and closes fd 3, e.g.
exec 3<
For those who prefer one-liners and doesnt have Bash-4.1+ available:
{ seq 0 255; ls -1 /proc/$$/fd; } | sort -n | uniq -u | head -1