Skip to content
Advertisement

Doesn’t sh support process substitution <(…)?

On a Centos 6 machine, this works:

JavaScript

and this doesn’t:

JavaScript

I get:

JavaScript

Nevermind the grep and tail. The problem is with the process substitution thingy: <(...)

Can someone tell me what sh does differently here?

[EDIT]

Thanks for the answers!

The problem arose while using capistrano for deployments. It defaults to using sh but I changed that to bash now. The reason I couldn’t do the normal piping is that when using tail -F | grep -q --line-buffered, grep won’t exit immediately after a match. There has to be one more edit to the file like echo "" >> catalina.out and this was not acceptable in my situation.

Advertisement

Answer

The syntax <(...) is only supported by BASH.

For any POSIX shell, use this approach:

JavaScript

i.e. move the stdin redirection in front of the if with a pipe. The if will pass stdin on to the grep.

if tail ...| grep won’t work since the if won’t be able to see it’s then/fi because the pipe separates processes.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement