Echo text with colours in your batch files, with the free sfk echo command for Windows, Mac OS X and Linux.
sfk echo [options] string [string2] [string3] [...]sfk tell [-spat] string [string2] [string3] [...]
prints the supplied string, which may contain color patterns:
print the following text in the selected color.
switch back to default color.
[[ print the '[' character, no not interpret the following word.
]] print the ']' character, do not interpret it.
-literal or -lit disables everything, even color patterns,
i.e. words in brackets like [red] are not changed.
-noline stay in the same line, print no linefeed.
if your string ends with \r, -noline is assumed.
for command chaining -noline requires -literal
and a command accepting binary data, like xed:
sfk echo -lit -noline "%1" +xed ...
-pure same as -literal -noline. use this always to send
chain input data as unchanged as possible, like
filenames from parameters, to following commands:
sfk echo -pure "%1" +xed "_/_\\_" ...
-spat activates slash patterns: \t=TAB \q=" \r=CR \n=LF
\xnn = any code with hex value nn. can be given
after -lit to use slash patterns without colors.
-join[line] join all into one line. line ends are stripped
from quoted multi line parms (full trim). multiple
string parameters are joined without blanks.
-lines print every given string as a single line.
command chaining supportsfk tell just prints to terminal, and never sends text
to a following command. always prefer this
if you just want to print an info to terminal.
sfk echo will send the given text to a following command
if it accepts text or filename list input.
to send a single string as unchanged as possible to a command
accepting binary data, like xed, use -literal -noline.
by default, echo produces only text data, not filenames.
to send this to file commands use +texttofilenames or +ttf.
echo -lines may produce filename lists directly.
quoted multi line parameters are supported in scripts
using auto indent. type "sfk script" for details.
use option -joinline to apply full trim.
see also: sfk help colors
web referencehttp://stahlworks.com/sfk-echoexamplessfk tell "[Red]error:[def] missing filename."
prints "error: missing filename." onto terminal.
sfk tell [Cyan]NOTE:[def] type the word [[red]] with brackets!
prints "NOTE: type the word [red] with brackets!" onto terminal.
sfk echo "[Green]mytext contains:[def]" +then filter mytext.txt+then forces echo not to pass its text to filter, but to
print it immediately. filter then prints the content of mytext.
sfk tell "[Green]mytext contains:[def]" +filter mytext.txt
same as above, but shorter. tell never sends text to following
commands therefore +then is not required.
sfk tell -nocconv -spat "\xc9\xcd\xbb\n\xba \xba\n\xc8\xcd\xbc\n"
print a graphical box using extended dos characters.
more infos under sfk ascii -dos and sfk help optsfk echo -spat "foo\nand\nbar" +tofile mydir\test1.txt
create a small text file with three text lines
sfk echo -pure "C:\in.txt" +xed -dump
send the string C:\in.txt as unchanged as possible to xed
and create a hexdump, to check that no (CR)LF was added.
sfk echo -pure -spat "foo\tbar" +xed -dump
send the word "foo" followed by tab character then "bar"
to xed and create a hexdump. "\t" is changed by -spat.
sfk echo -lines 100 101 102 +perline "web .$text/status.xml"
load page /status.xml from three local ip's .100, .101, .102
sfk color colorname
switches the text color of terminal (command line).
supported color names are:
white grey red green blue yellow cyan magenta black