User Feedback :: No Bash Command Substitution?!



Using 3.4.4, it seems that command substitution doesn't work in DSL.

Code Sample

dsl@ttyp1[dsl]$ sudo cat Events >( grep -i "Linux" - > test.txt )
07:19:DSL 1.3.1 Released
08:02:DSL 1.4 Released.
08:09:Linux World
08:10:Linux World
08:11:Linux World
10:31:Halloween
cat: /dev/fd/63: No such file or directory


sudo, or it would hang at the end of cat, because it can not access the non-existent file.

Can't sudo mkfifo /dev/fd/63, or touch /dev/fd/63

/dev/fd points to /proc/self/fd/
/proc/self points to /proc/n/ where n changes on almost every command

Basically, there is no fifos at /dev/fd/xx and command substitution won't work.

How can I create them, or can they be added for the next maintence 3.4.9

I'm not sure what you're trying to do... but you could try something like
Code Sample
$ cat Events | grep -i "Linux" > test.txt
or if you need stdout as well
Code Sample
$ cat Events | grep -i "Linux" | tee test.txt
Also, I don't think you're trying to do command substitution.

EDIT: manpage says process substitution.  Bash will use temporary files if /dev/fd/?? (i.e. `echo <(true)` ) doesn't exist... so your syntax is wrong?  If you need to use it, maybe try something like
Code Sample
$ grep -i "Linux" <(cat Events) > test.txt #redundant

For bash-specific command substitution, the opening parenthesis is preceded by a $:
$(grep -i "Linux" -)
You can also use backticks for compatibility with other shells:
`grep -i "Linux" -`

I think the first example from ^thehatsrule^ is most logical though.

mikshaw: using - will require something from stdin, and using command substitution only provides output... so wouldn't that just stall?
Well, I would need the command substitution to do:
Code Sample

cat /dev/ptyu1 | fgrep --line-buffered -e "New Title" -e "Icy-Name" -e "icy-url" | sed -e /"access_http debug: "/s/// -e '/Icy-Name/i\
--
' -e /"Meta-Info: icy-url"/s//"Icy-Url"/ -e /"New Title="/s//"Now Playing: "/ | tee >(grep --line-buffered "Icy-Name" | sed -e /"Icy-Name"/s/// > CurrentStation.txt) >(grep --line-buffered "Now Playing" | sed -e /"Now Playing"/s///) >(nc)


or

Code Sample
command1 | tee >(command2) >(command3) >(command4) | command5


Or in simpler terms, allow for multiple programs writing multiple files from the same base file read, which when using pipes, named pipes, or pseudo-terminals needs to be done like this since only one program can read or write to it at a time.

Edit: The example I used in the first post was just that, an example. :/

Next Page...
original here.