<span style= "FONT-SIZE:18PX;" >seq 9 | Sed ' h;g ' | Awk-v rs= ' {for (i=1;i<=nf;i++) printf ("%dx%d=%d%s", I, NR, I*nr, I==nr? ") \ n ":" \ T ")} ' </span>
Pre-Knowledge:
SEQ: Generating a sequence
SED: pattern space and storage space
H: Append The contents of the pattern space to the hold space\n
G: Overwrite the data in the storage space with the pattern space
The mode space used when outputting, storage space is just a scratchpad
1, SEQ generated 1, and then added to the SED mode space, H appends the value of the mode space to the storage space, the mode space is 1, the storage space is \n1, and then copied to the mode space, when the mode space is \n1, the final output, the \n1 passed to awk
Awk-v rs= '
‘
{
for (i=1;i<nf;i++) {
printf ("%dx%d=%d%s", I,nr,i*nr,i==nr? \ n ': ' \ t ');
}
}
‘
Note: rs= ' indicates a blank line as a separator
2, SEQ generated 2, and then added to the mode space, when the mode space is 2, storage space for \n1; H appends 2 to the storage space, at which time the storage space is \n1\n2;
The G then copies the \n1\n2 to the pattern space, when the pattern space is \n1\n2 and outputs to awk, at which time awk handles the \N1\N2
3, repeat the above process, know to print out 99 multiplication table
Although a word on the implementation of the 99 multiplication table, but compared to high-level language is a bit difficult ah!
SED print 99 multiplication table