Shell command combination with the free Swiss File Knife allows to write easy but powerful single-line scripts, for instant file and text processing.
sfk command chaining reference:
several commands can be combined in a so-called "command chain".
this is done by appending command names prefixed by "+", for example:
sfk list docs .txt +ffilter -+foo
"list" produces a filename list and passes this to "filefilter".
ffilter reads the contents of these files looking for word "foo".
chain data types
three types of data can be passed from one command to another:
- filename lists.- plain text records (lines).- stream text or binary data.
output is dependent on command. for example, sfk select produces
filename lists, sfk filter makes plain text records, xex/xed can
produce streams of text or binary data.
chain data type conversion
vice versa, some commands accept filenames, or text input, or both.
depending on what you want to do you may have to convert between
this types of data. this can be done by the keywords:
+texttofilenames or +ttf+filenamestotext or +ftt
however, most sfk commands try to do such conversions automatically.
using chain data between commandssfk cmd1 ... +then cmd2 does not pass any data to cmd2,
prints cmd1 output to terminal.
sfk ... +toterm dumps current chain content to terminal.
sfk ... +tofile outfile dumps chain content to file outfile.
sfk ... +tovoid +cmd2 does not pass any data to cmd2,
drops cmd1 chain text silently.
in all cases, the chain is cleared. if another command is following,
it will receive no input from the chain.
using chain data with call / label / endsfk ... +call myfunc passes no chain data into myfunc
sfk ... +tcall myfunc passes text data into myfunc
sfk ... +fcall myfunc passes filenames into myfunc
sfk label ... +end returns no chain data
sfk label ... +tend returns text data
sfk label ... +fend returns a filename list
scope and lifetime of options
most options are valid only for the command where they are specified.
if another command follows in the chain, the option is reset.
but some options may also be specified on a global scope.
read more on that under "sfk help options".
more in the SFK Book
the SFK Book contains long examples with input,
output, script and detailed command explanations.
type "sfk book" for more.
see alsosfk batch create an example script
sfk help var how to use sfk variables
sfk script about sfk scripting
sfk call calling a function in a script
sfk label possible options with label
sfk if conditional execution
sfk goto jump to a local label
sfk for repeat commands n times
sfk load load text or data for chaining
see alsosfk script - place sfk commands into a multi-line script file
sfk samp - examples for batch embedded sfk scripts