Well, it is important to remember that <(...) or >(...) becomes a WORD openable a s a file name, like in ksh ' /dev/fd/7 ', not just a string but with implied separation, so you cannot use it in sed like this, because it looks like 2 arguments. (David Korne says he hadn't thought of it for such usage. You can strip the separation by passing it in a shell subroutine call.):
So, some of this is silly, as 'xxx < <(yyy)' is just 'yyy | xxx'. These <() >() constructs are for places where you need a file name but want a pipe, like this:
In some UNIX, you have /dev/stdin, /dev/stdout and /dev/stderr, really /dev/fd/0, 1 and 2, which is enough for the occasional obstinate program with no shorthand for stdin/stdout like '-' in tar f, cat, etc. These autoomatically managed named pipes are great if there are more than 2 parallel processes. The bash management of these named pipes is flawed, BTW, bug reported -- they accumulate in /var/tmp. While the ksh in /dev/fd/# UNIX just does a pipe() call and harvests the /dev/fd/# names, the bash implementation uses mknod or mkfifo persistent named pipes, which work a bit different, a pipe() inside open() for one side and connecting to that pipe for the other side, I forget which goes first. For instance, this works to give a c progrqam a robust parallel sort, using the same named pipe twice, for input then for output. Part of the reason this works in the nature of sort, reading all input, sorting and then writing all output:
You can see the overhead of name collision, pipe creation and pipe cleanup, plus if someone else comes along and opens your pipe, it would mess things up. Named pipes were intended for a crude sort of server, where a server process keeps opening the pipe waiting for a client to open the other side the other way, and spinning off a child, somewhat like inetd spinning off server processes for every tcp connection, but it seems tricky to use the fd bidirectionally in a script, without which it is a unidirectional service, like writing a queue.
Some shells consider <() or >() subshells as your login shell's child jobs, with all the start-end notifications and such. Firing up in a subshell means they are not your children, so toss in a protective set of () if you want quiet.
Ksh also has {} to create redirection and inheritance like () but without a fork() to a subshell, but the rules are a bit demanding, so I ignore them. It turns our fork() is 10 times cheaper than execvp(), so for shell speed, count your exec's and use the built-in equivalents like read for line, pattern matching for `grep`, etc. Many nominal PERL scripts are amazingly shellish!
Hi,
Can the cd command be invoked using pipes???
My actual question is slightly different. I am trying to run an executable from different folders and the path of these folders are obtained dynamically from the front end. Is there a way in which i can actually run the executable... (2 Replies)
I'm investigating strange behaviour on two boxes (Sun OS 5.10 and AIX 5.1) in ksh
have used $? to get exit codes returned:-
137 and 34
where can I find what these mean?
thank you (1 Reply)
Hi everybody, I'm writing to know what the following event stands for. I know that the following event is about a "su to root" action but I don't have any Idea about what action could rise this message. For example If an acction performed by the root crontab, a sudo command or something like that.... (1 Reply)
Hi,
thanks for b4. can anyone tell me why following not working:
noUsers=$(who | cut -d" " -f1 | wc -l)
What i'm trying to do is get a list of logged on users and pass it to 'wc -l' and store the output to a variable. Any ideas? (1 Reply)
im trying to figure out how to do the following:
using pipes to combine grep and find commands to print all lines in files that start with the letter f in the current directory that contain the word "test" for example?
again using pipes to combine grep and find command, how can I print all... (1 Reply)
Hello all, I am trying to learn more about programming Unix pipes in C.
I have created a pipe that does od -bc < myfile | head
Now, I am trying to create od -bc < myfile | head | wc
Here is my code, and I know I might be off, thats why I am here so I can get some clarification.
#include... (1 Reply)
Hi all,
I was trying see some CPU utilization of a Red hat Linux machine using 'top' command.
Any way I got high level idea from the out puts,
but when I observed the following line:
Cpu(s): 7.4%us, 0.5%sy, 0.0%ni, 91.6%id, 0.4%wa, 0.0%hi, 0.1%si, 0.0%st
I couldn't make out what... (2 Replies)