| 
 | 
The following awk program simulates (crudely) the history facility of the C shell:
   $1 == "=" {  if (NF == 1)
                        system(x[NR] = x[NR-1])
                     else
                        for (i = NR-1; i > 0; i--)
                                if ( match(x[i],$2) ) {
                                        system(x[NR] = x[i])
                                        break
                                }
                        next
                  }
   
   $1 != "="      { system(x[NR] = $0) }
A line containing only = re-executes the last command
executed. A line beginning with
=<space>cmd re-executes the last command
whose invocation included the string cmd. Otherwise, the
current line is executed.