From: Alfie Costa (agcosta@gis.net)
Date: Tue Mar 21 2000 - 03:25:39 CET
On 19 Mar 00, at 10:40, Michele Andreoli <mulinux@sunsite.auc.dk> wrote:
> > 	[ "$c" ]  &&  charlist=`ls -Uo "$@" | awk '{ printf "%s ", $4 }'`
> 
> My problem is: you use awk, here, but shell is enough
> 
> 		set -- $string	; echo $4
Maybe we think alike -- I attempted something like that the other day, after 
forgetting some details, but the problem doesn't seem to be a true problem 
after all.  Example: suppose there's two files in a directory, 'foo1' and 
'foo2'.
Just now I forget how the exact 'ls -Uo' output ought to look, and am typing 
this in Pegasus/Win95 where it is inconvenient to check, but probably if we do 
an 'ls -Uo *' of this dir it should look sort of like this:  
drwxrwxr-x igor monsters 222 Oct 31 1999 foo1
drwxrwxr-x igor monsters 897 Nov 11 1999 foo2
Whatever it really looks like, the important thing is that column 4 has the 
file size, the rest doesn't effect the program.  Piping this output to 
`awk '{ printf "%s ", $4 }'` produces:
222 897
...which is the thing desired, but piping that same 'ls -Uo' output to 
`set -- $string	; echo $4` would result in:
222
...because the 'ls -Uo *' output is on multiple lines, which 'awk' is happy 
with, but which 'set' doesn't like.  With a single line of input, they both do 
the same thing, (which is confusing, maybe I should write better comments), but 
for multiple lines, 'set' and 'awk' are different.
Anyway, it's good you mentioned this, because looking at that 'set -- $string' 
line, it shows how I didn't need any of that "set dummyoption" stuff.  That is, 
before, to protect a leading hyphen from 'set' I had written:
eval set dummyoption ${opts:--}
shift			
...but now it's plain enough that this is simpler:
eval set - ${opts:--}
So, this has been educational for me, and I'll e-mail you 'crudewc' with that 
line changed, and a better comment.  (Doesn't seem a big enough change to put 
on the list...)
---------------------------------------------------------------------
To unsubscribe, e-mail: mulinux-unsubscribe@sunsite.auc.dk
For additional commands, e-mail: mulinux-help@sunsite.auc.dk
This archive was generated by hypermail 2.1.6 : Sat Feb 08 2003 - 15:27:13 CET