Команды SFK


    1        2        3        4        5        6        7        8        9        10    

Раздел 4. Text Processing - Обработка текста
addhead | addtail | count | difflines | filter | head | joinlines | linelen | load | ofilter | perline | printloop | replace | run | runloop | snapto | sort | strings | tail | xed | xex | xreplace |

Help:   Рус   |   Eng        Refer:   Рус   |   Eng  

Команда: tail
sfk tail [-lines=n] [-f[ollow] [filename]
sfk ... +[t]tail [-lines=n]

   1. print last lines of a file, optionally following changes.
      to use file content processing, provide a single filename.

   2. print last text lines procuded by a previous command.
      to process chain text ttail is recommended.

   options
      -lines=n     print last n lines (default is 10).
      -follow      or -f waits for file changes, printing them endlessly.
                   if file is recreated or shrunk, rereads the last lines.
                   to post-process tail output, e.g. with +filter, always
                   add +loop at the end of the command sequence.
      -nowait      if tail is reached multiple times in a chain by +loop
                   then do not wait for a file size change but force
                   stepping of the command chain.
      -quiet       do not tell verbosely about read restarts.
      -polltime=n  with -follow, specifies the delay in milliseconds before
                   the file is checked again for changes. default is 500.
      -altsize     use a different method to determine the file size
                   (stat instead of seek). may help if the default method
                   fails to read the file, or to improve performance.
      -verbose     tell in detail what is done.

   see also
      sfk filter -tail=n  read and search last n lines of text files.
      sfk view     GUI tool to view all text files of a folder, then jump
                   through file ends by ctrl+end.

   web reference
      http://stahlworks.com/sfk-tail

   examples
      sfk tail -follow logs\access.log
         immediately lists last lines, then all added lines over time.
      sfk tail -f c:\temp\log.txt +filter -+error: -+warning: +loop
         endless filter of error and warning messages from log.txt.

   example sfk script with conditional execution
     file logfilter.txt:
       sfk label checklog
          +tail -follow logfile.txt
          +tee toterm +storetext
          +filter -+error: -justrc
          +if "rc>0" call myalert
          +gettext +filter -+alldone: -justrc
          +if "rc>0" stop
          +loop +end
       sfk label myalert
          +then run -yes "myalert.bat" +end
     sfk script logfilter.txt
        will run myalert.bat whenever errors appear in logfile.txt.
        the script stops as soon as "alldone" appears in the log.
        to allow double filtering of the chain text it must be
        stored before the first filter, then restored.