Subj : Re: about to blow a gaske To : Angus Mcleod From : Deuce Date : Mon May 23 2005 01:40 pm Re: Re: about to blow a gaske By: Angus Mcleod to Deuce on Sat May 21 2005 21:15:00 > 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 > > > 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 tryin > > 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. > > > Ah, but you're using cat for that, not less. less does not concatenate... which is exactly what cat is actually for. But, your example does show some oddities with bash, that's for sure. What is it that you're redirecting? Assuming it's less and was merely removed for clarity... Hrm... interesting... "less > *" using the sh shell will actually CREATE the file named '*' and say "Missing filename" I'm not used the whole sh class of shells myself, I almost never use them. I'd need to dig about in the man pages quite a bit to discover what is actually happening. I'm must more used to the csh shell replacements. --- þ Synchronet þ ``Penguins make tasty snacks'' .