Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I suspect this has been answered before, but I don't know what this is called, so I can't really search for it.

How come this works :

$ grep H=p <(udevadm info /dev/ttyUSB0)
E: ID_PATH=pci-0000:00:1d.0-usb-0:1.5.2:1.0

But this doesn't ? :

$ sudo grep H=p <(udevadm info /dev/ttyUSB0)
grep: /dev/fd/63: No such file or directory

Nevermind the fact that sudo isn't necessary in this case, please.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

The shell is replacing <(udevadm info /dev/ttyUSB0) with /dev/fd/63 (after dup'ing the read end of the pipe to fd 63) before running the command. However, sudo closes all file descriptors greater than 2 by default. You can change this by using sudo's --close-from flag, but there's a better way:

sudo bash -c 'grep H=p <(udevadm info /dev/ttyUSB0)'

share|improve this answer
    
Neat, thank you. Of course I'll have to practice with it to really learn/understand it in time ! –  robut Jan 25 at 2:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.