Less -ofilename or –log-file=filename option causes less to copy its input to the named file as it is being viewed. This applies only when the input file is a pipe, not an ordinary file. If the file already exists, less will ask for confirmation before overwriting it.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
ps -aux | less ## only displays the output of ps -aux ps -aux | less -o mytmpfile ## saves the output to mytmpfile ls -l ps -aux | less -o mytmpfile ## gives a warning since mytmpfile already exist ## Warning: "mytmpfile" exists; ## Overwrite, Append or Don't log? A ps -aux | less -O mytmpfile ## no warning is given, overwrites mytmpfile rm mytmpfile |