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