Команды 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  

Команда: perline

Run a command per text line in SFK scripts

with the SFK perline command.
sfk ... +perline "command #text"

for every chain text line run sfk commands(s)
like a sub function, passing the text as parameters.

options
   -yes        really execute. default is just to simulate
               what would be done.
   -setvar x   put whole line text into variable x,
               for easy use in a call without parameters.
   -nohead     does not display the [simulating:] info text.
   -stoprc=n   stop on return code >= n instead of default 9.
   -nostop     do not stop on errors regardless of rc.

command string format
   each word, separated by whitespace, is a parameter.
   to fill in the current chain text line use $text or #text.
   perline uses a strict command format by default.
   to insert characters $ or # as is type $$ or ##
   with option -spat, slashpatterns like \t \q \xnn are supported.
   to use multiple words as one parameter use -spat and \q ... \q

quoted multi line parameters are supported in scripts
   using parm trim. type "sfk script" for details.

recursion limit
   if the called function calls another function by call
   or perline this should not be nested too often,
   otherwise sfk may crash.

see also
  sfk run        for the full command string format
  sfk stacksize  test available stack size

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

examples
  sfk echo -lines 100 101 102
   +perline -spat "web -nodump \q.$text/xml/restart.xml\q"
     on local ip's .100 .101 and .102
     call a web command /xml/restart.xml.   [17]
  sfk sel mydir .jpg +perline -spat "echo <img src=\q#ufile\q 
   width=\q400\q> +tofile -append print.html"
     create a file print.html containing all .jpg files of
     folder mydir, shown with 400 pixels width. [28]
  sfk load in.txt +perline -setvar l "call doline" -yes +end
     within a script: on every line set variable l with
     the full line text, then call label doline.
  sfk load foldernames.txt +perline "sfk list #qtext" -yes
     load a file with folder names and list contained files.
     qtext adds quotes around the names for safety.