Skip to content

Instantly share code, notes, and snippets.

@d630
Last active June 11, 2016 17:38
Show Gist options
  • Save d630/3acc781b41e16aaaa8452651203d241d to your computer and use it in GitHub Desktop.
Save d630/3acc781b41e16aaaa8452651203d241d to your computer and use it in GitHub Desktop.
bash: PS as WORD in for-loop
for I in <(ls -1ld /) <(ls -l1d /)
do
exec 3<"$I" || exec 3<&-;
echo is:$I
o=$(cat 0<&3)
echo $o
done
@d630
Copy link
Author

d630 commented Jun 7, 2016

gets:

is:/dev/fd/63
drwxr-xr-x 21 root root 4.0K May 20 19:16 /
bash: /dev/fd/62: No such file or directory
is:/dev/fd/62
bash: 3: Bad file descriptor

@d630
Copy link
Author

d630 commented Jun 7, 2016

workaround:

for I in <(ls -1ld /)\ <(ls -l1d /)
do 
        cat ${I}
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment