Subj : Re: about to blow a gaske To : Deuce From : Angus Mcleod Date : Sat May 21 2005 09:15 pm Re: Re: about to blow a gaske By: Deuce to Angus Mcleod on Sat May 21 2005 10:09:00 > > > first.ext second.ext third.ext fourth.ext etcetera.ext > > > > then the shell should try to truncate 'first.ext', then execute > > 'second.ext' with 'third.ext fourth.ext etcetera.ext' as arguments and > > redirect STDOUT to 'first.ext'. > > > > I'm not sure why '*' evaluated to a list of files, doesn't bring about th > > same result. > > You would need a ; between first.ext and second.ext for the results you > described. The reason you get an ambiguous redirect is that you're trying t > redirect to multiple files... the shell has no clue what you mean by that. No, I can't agree with that logic. If I place a ; in there, I am actually running two separate processes, as in a "list". If I run > output < input sort what happens? 'sort' reads 'input' as a STDIN, sorts it, and writes the results to 'output' on STDOUT. If I do > output ls then the output from the 'ls' command should go to 'output' on STDOUT. If I have a file called 'second.ext' which is a symlink to '/usr/bin/cat' and I run second.ext third.ext fourth.ext etcetera.ext then I should get the contents of the files 'third.ext', 'fourth.ext'. and 'etcetera.ext' concatenated on STDOUT. Checking... $ ln -s /usr/bin/cat second.ext $ echo THIRD > third.ext $ echo FOURTH > fourth.ext $ echo ETCETERA > etcetera.ext $ second.ext third.ext fourth.ext etcetera.ext THIRD FOURTH ETCETERA $ Yep! Therefore, if I ran the original example: $ > first.ext second.ext third.ext fourth.ext etcetera.ext $ cat first.ext THIRD FOURTH ETCETERA $ Yep! Works exactly as I thought it should. But *why* does it *not* work, if the entire list of files is generated with a pattern? $ echo *.ext etcetera.ext first.ext fourth.ext second.ext third.ext $ rm first.ext second.ext $ ln -s /usr/bin/cat first.ext $ > *.ext -bash: *.ext: ambiguous redirect $ > etcetera.ext first.ext fourth.ext second.ext third.ext $ cat etcetera.ext FOURTH SECOND THIRD $ See? It works when you type the entire list, but if you use a shell substitution, it fails. The answer has to be something to do with the way the command line expansion occurs. Perhaps some precedence issue? Dunno. Interesting. --- þ Synchronet þ Cry "Softly" then hit hard at The ANJO BBS .