,
address2]]w
fileAppend contents of pattern space to file. This action occurs when the command is encountered rather than when the pattern space is output. Exactly one space must separate the w
and the filename. A maximum of 10 different files can be opened in a script. This command creates the file if it does not exist; if the file exists, its contents are overwritten each time the script is executed. Multiple write commands that direct output to the same file append to the end of the file.
# Store tbl and eqn blocks in a file: /^\.TS/,/^\.TE/w troff_stuff /^\.EQ/,/^\.EN/w troff_stuff