awk and shell question

Ganga Varatharajan ganga at megadata.mega.oz
Tue Oct 3 17:47:42 AEST 1989


>From article <4926 at macom1.UUCP>, by larry at macom1.UUCP (Larry Taborek):
> 
> USER=`cat /etc/passwd | awk -F: '{printf("%-8.8s %-20.20s\n",$1,$5)}'`
> echo $USER
> 
> this works, but I think what you really want is:
> 
> cat /etc/passwd | awk -F: '{printf("%-8.8s %-20.20s\n",$1,$5)}'
> 
> without the USER=`

I'm trying to alias d (csh) as:
% dirs -l | awk '{ for (i = 1; i < NF+1; i++) { print i-1,$i } }'
to list the directory stack one per line and numbered.

% alias d "dirs -l | awk '{ for (i = 1; i < NF+1; i++) { print i-1,$i } }'"
gives
% $i undefined variable.

% alias d 'dirs -l | awk \'{ for (i=1; i < NF+1; i++) { print i-1,$i}}\' '
gives
% unmatched '

So I use
% alias d "dirs -l | awk -f ~/.dirlist"
which is slow.

Any suggestions?

Thanks
Ganga.



More information about the Comp.unix.wizards mailing list