awk and shell question

Ben Lotto ben at nsf1.mth.msu.edu
Fri Oct 6 00:52:08 AEST 1989



On 3 Oct 89 07:47:42 GMT,
ganga at megadata.mega.oz (Ganga Varatharajan) said:

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

Try the following:

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

The problem is that any variable is automatically evaluated when
enclosed in double quotes.  So when you get to the variable, end the
double quotes and enclose the variable you want in single quotes.
--

-B. A. Lotto  (ben at nsf1.mth.msu.edu)
Department of Mathematics/Michigan State University/East Lansing, MI  48824



More information about the Comp.unix.wizards mailing list