How to do things
AI Noob vs. Pro

List biggest files
List newest files
Show subdir sizes
Search in files
Replace word in files
List dir differences
Send files in LAN

Free Open Source:

Swiss File Knife

a command line
multi function tool.

remove tabs
list dir sizes
find text
filter lines
find in path
collect text
instant ftp or
http server
file transfer
send text
patch text
patch binary
run own cmd
convert crlf
dup file find
md5 lists
fromto clip
hexdump
split files
list latest
compare dirs
save typing
trace http
echo colors
head & tail
dep. listing
find classes
speed shell
zip search
zip dir list

Depeche View
Source Research
First Steps

windows GUI
automation

command line
file encryption

free external tools,
zero install effort,
usb stick compliant:

zip and unzip
diff and merge
reformat xml
reformat source

cpp sources

log tracing
mem tracing
hexdump
using printf

articles

embedded
stat. c array
stat. java array
var. c array
var. java array
view all text
as you type
surf over text
find by click
quick copy
multi view
find nearby
fullscreen
bookmarks
find by path
expressions
location jump
skip accents
clip match
filter lines
edit text
highlight
load filter
hotkey list
receive text
send in C++
send in Java
smooth scroll
touch scroll
fly wxWidgets
fly over Qt
search Java

Supersonic Text File Search - Free Download

search and replace text within text and binary files with the free sfk replace tool for the Windows (7/Vista/XP), Mac OS X and Linux command line.
  • Download the free Swiss File Knife Base from Sourceforge.
  • Open the Windows CMD command line, Mac OS X Terminal or Linux shell.
  • OS X : type mv sfk-mac-64.exe sfk and chmod +x sfk then ./sfk
  • Linux: type mv sfk-linux-64.exe sfk and chmod +x sfk then ./sfk. OS X and Linux syntax may differ, check the help within the tool.
sfk replace singleFile [-text] /src/dst/ [pattern2] [...] [-yes]
sfk replace -[s]pat -bin[ary] /A0A1A2/B5B6B7/ -dir anydir -file .ext1 [-yes]
sfk rep [-dump [-wide]] -bylist words.txt file1 [file2 ...] [-yes]

replace text or binary data in text and binary files.
may replace many different patterns in parallel.

Multiple search patterns are executed in the given sequence. Mind this
if they overlap, e.g. /foo/bar/ /foosys/thesys/ makes no sense (foo is
replaced by the first expression, so the 2nd one will fail to match).

by default, replace functions run in SIMULATION mode,
   previewing hits without changing anything. add -yes to apply changes.
   Changing binaries may lead to unpredictable results, therefore keep
   backups of your files in any case.

license notice
   this is the open source version of sfk replace.
   replacing source / target patterns of different length is slower
   and may require much memory compared to replacements of same length.
   SFK Plus or XE contain a different implementation with high performance.

subdirectories are included by default
   the sfk default for most commands is to process the given directories,
   as well as all subdirs within them. specify -nosub to disable this.

options
   -nosub        do not include files in subdirectories.
   -nobin[ary]   skip binary files.
   -case         case-sensitive text comparison. default is case-insensitive
                 comparison for all -text strings, but NOT for -bin blocks.
                 case-sensitive comparison is faster then case-insensitive.
                 for further details type: sfk help nocase
   -nocase       force case-insensitive comparison ALSO on -bin patterns.
   -pat          starts a list of search or replace patterns of the form
                 xsrcxdstx where x is the separator char, src the source
                 to search for, and dst the destination to replace it with.
                 e.g. /foo/bar/ or _foo_bar_ both replace foo by bar.
                 -pat is not required if a single filename is given.
   -text         the same as -pat, starting a text pattern list.
   -spat         same as -pat but also activates slash patterns like \t .
                 type "sfk help pat" for the list of possible patterns.
   -spats[trict] same as -spat, but stops with error on undefined
                 slash patterns like \m in C:\myproj. every slash
                 must then be escaped, e.g. using C:\\myproj.
   -bin[ary]     starts a list of binary replace patterns, specified
                 as hexcode like /0A0D/2020/
   -bylist x.txt read search patterns from a file x.txt, supporting
                 multiple lines per pattern. (add -full for more.)
   -bylinelist x read /from/to/ or just /from/ patterns from a file x
                 with one pattern per line. (add -full for more.)
                 -by(line)list does not support sfk variables.
                 to use variables in patterns create an sfk script
                 with patterns as parameters. "sfk script" for more.
   -recsize      with same length replacements: set input record size
                 for processing (default=100k)
   -firsthit     process only first found pattern match per file.
   -maxscan=nm   stop searching after (approximately) first n megabytes
                 per file. can be used only with same length replace.
   -quiet        do not show progress infos.
   -stat         show statistics like hits per pattern and no. of files.
   -perf         show performance statistics.
   -memlimit=nm  with different-length replacements, files must be loaded
                 into memory for processing. the default limit for memory
                 use is 300 MB. set -memlimit=500m to select 500 MB.
   -full         print full help text telling about -bylist pattern files,
                 special character case sensitivity and nested or repeated
                 replace behaviour.

output options
   -dump         create hexdump of search hits or replaced text.
    -wide        with -dump: show 16 bytes per line.
    -lean        with -dump: show  8 bytes per line.
   -dumpfrom     always dump search hits but not replaced text.
   -dumpall      dump search text and replaced text.
   -nodump       do not create a hexdump, list only matching files.
   -astext       no hexdump, but print search hits as plain text.
                 use this only with plain text files, not binary.
   -showle       highlight CR/LF line endings in hex dump output
   -context=n    with hexdump: show additional n bytes of context.
   -reldist      with hexdump: tell relative distances to previous hits.
   -to dir\$file write output files to given path. for details about
                 output file masks, type "sfk help opt" or "sfk run".
   -tofile x     write output data to a single output filename x
                 (which is not interpreted as a mask but taken as is).
   -more[n]      pause output every 30 or n lines.

return codes for batch files
   0 = no matches, 1 = matches found, >1 = major error occurred.
   see also "sfk help opt" on how to influence error processing.

about nested replacement patterns
   sfk replace myfile.dat /foo/bar/ /bar/goo/
   with SFK base, "foo" will be replaced by "bar" and then
   immediately "bar" is replaced again by "goo".
   with SFK Plus or XE, a replaced part of text is not replaced
   again in the same command, so "foo" stays replaced by "bar".

unexpected repeat replace behaviour
   depending on the input data and search/replace expressions,
   it can happen that running the same replace multiple times
   on the same file produces further hits that didn't exist
   in the first run. add option -full to read more on this.

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

performance notice
   the system may cache output file(s), writing to disk in
   background after sfk has finished. subsequent batch file
   commands may execute slower.

office file support
   sfk ofind        search in .xml text file contents of
                    office files like .docx .xlsx .ods .odt.
   sfk help office  for more infos and options

see also
   --- open source commands ---
   sfk xfind     search  wildcard text in   plain text files
   sfk ofind     search  in office files    .docx .xlsx .ods
   sfk xfindbin  search  wildcard text in   text/binary files
   sfk xhexfind  search  in text/binary with hex dump output
   sfk extract   extract wildcard data from text/binary files
   sfk filter    filter  and edit text with simple wildcards
   sfk find      search  fixed    text in   text        files
   sfk findbin   search  fixed    text in   text/binary files
   sfk hexfind   search  fixed    text in        binary files
   sfk replace   replace fixed    text in   text/binary files
   --- freeware commands ---
   sfk view      GUI tool to search text as you type
   --- xe commercial commands ---
   sfk replace   replace fixed    text with high performance
   sfk xreplace  replace wildcard text in   text/binary files
   sfk help xe   about SFK XE and xreplace with SFK Expressions.

beware of Shell Command Characters.
   to find or replace text patterns containing spaces or special
   characters like <>|!&?* you must add quotes "" around parameters
   or the shell environment will destroy your command. for example,
   pattern /foo bar/other/ must be written like "/foo bar/other/"
   within a .bat or .cmd file the percent % must be escaped like %%
   even within quotes: sfk echo -spat "percent %% is a percent \x25"

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

common usage errors
   sfk hexfind in.txt "/foo\r\n/"
      will not find "foo" at line ends, but searches literal
      strings like "slash and r". add option -spat to enable
      slash patterns, converting \r\n to real CRLF codes,
      or use xhexfind where slash patterns are default.
   sfk hexfind mydir "/foo*bar/"
      will not find "foo" and "bar" with any characters
      inbetween, but searches a literal star "*".
      use xhexfind to enable search with wildcards.
   sfk rep in.txt "/foo[0.1000 bytes]bar/---/"
      will not replace up to 1000 bytes between "foo" and "bar",
      but replaces a literal string "foo" then "[1000 bytes]"
      then "bar". use xed or xreplace instead.

examples
   sfk replace myfile.dat "/Lemon/Curry/"
      replace Lemon by Curry within myfile.dat. search is
      case-insensitive, therefore "lemon" will be replaced as well.
      the quotes "" are optional here.
   sfk replace -pat /FooCase// -dir . -file .txt
      search for FooCase in all .txt files below current directory.
      note that if you leave out the single fileOrDir parameter,
      you have to say -[s]pat, -bin or -text first to tell clearly
      that you will specify the target fileset later on.
   sfk rep -spat "/The foo/The\tbar/" -dir mydocs
      replaces "The foo" by "The" and "bar" separated by TAB char,
      within all files within mydocs.
   sfk rep -binary /1A/20/ -dir docs -file .txt .info .note
      replaces all bytes with code 0x1A by code 0x20, in all .txt,
      .info and .note files, in directory docs and all subdirectories.
   sfk replace tmp\image.dat -bylist patches.txt
      searches for source patterns in file tmp\image.dat,
      replaces by patterns specified in patches.txt
   SFK Base and XE: swap text in two steps
   sfk -yes rep io.txt /foo34/foo99/ /foo12/foo34/ +rep /foo99/foo12/
      replaces foo12 by foo34 and vice versa. with SFK Base, a word
      which is replaced may be replaced again by a following pattern,
      therefore the intermediate step: turn foo34 into something
      not used anywhere in io.txt, then replace foo12, then replace
      the intermediate pattern back in a second replace command
      on the same file.
   SFK XE only: swap text in one step
   sfk rep io.txt /foo12/foo34/ /foo34/foo12/ -yes
      replaces foo12 by foo34 and vice versa. with XE, a word which
      is replaced is not looked at again in the same command, so
      "foo34" from the first pattern is not changed by the 2nd.
   sfk hexfind mydir -pat /FooCase/ +list -late
      do not replace, just find binary files containing "FooCase",
      then list them sorted by time. also accepts -bylist files.
   sfk replace -binary /666f6f/626172/ -dir mydir -file .dat
      replace binary data with hex values 0x66, 0x6f, 0x6f
      by data with values 0x62, 0x61, 0x72 in all .dat files.
 
example with output:

   preparing a replacement of pattern "class Foo".

      sfk rep testfiles "/class foo/class Other/" -dump

   output:

      [simulating:]
      [total hits/matching patterns/non-matching patterns]
      testfiles\FooBank\GUI\include\FooGUI.hpp: hit at offset 0x64
      >6F6E616C 6974792E< onality. 00000054
      >0D0A2A2F 0D0A0D0A< ..*/.... 0000005C
      >636C6173 7320466F< class Fo 00000064
      >6F475549 0D0A7B0D< oGUI..{. 0000006C
      >0A707562 6C69633A< .public: 00000074
      [001/1/0] testfiles\FooBank\GUI\include\FooGUI.hpp
      testfiles\Formats\12-foo-jam.txt: hit at offset 0xE6C
      >6F6E616C 6974792E< onality. 00000E5C
      >0D0A2A2F 0D0A0D0A< ..*/.... 00000E64
      >636C6173 7320466F< class Fo 00000E6C
      >6F475549 0D0A7B0D< oGUI..{. 00000E74
      >0A707562 6C69633A< .public: 00000E7C
      [001/1/0] testfiles\Formats\12-foo-jam.txt
      38 files checked, 2 would be changed.
      [add -yes to execute.]

   the input data is listed as hex and ascii, with the hits highlighted.
sfk replace singleFile [-text] /src/dst/ 
   [pattern2] [...] [-yes]
sfk replace -[s]pat -bin[ary] 
              /A0A1A2/B5B6B7/ -dir anydir
              -file .ext1 [-yes]
sfk rep [-dump [-wide]] -bylist words.txt 
                          file1 [file2 ...]
                          [-yes]

replace text or binary data in text and 
binary files. may replace many different
patterns in parallel.

Multiple search patterns are executed in 
the given sequence. Mind this if they
overlap, e.g. /foo/bar/ /foosys/thesys/
makes no sense (foo is replaced by the
first expression, so the 2nd one will fail
to match).

by default, replace functions run in 
SIMULATION mode,
   previewing hits without changing 
   anything. add -yes to apply changes.
   Changing binaries may lead to
   unpredictable results, therefore keep
   backups of your files in any case.

license notice
   this is the open source version of sfk 
   replace. replacing source / target
   patterns of different length is slower
   and may require much memory compared to
   replacements of same length. SFK Plus
   or XE contain a different implementation
   with high performance.

subdirectories are included by default
   the sfk default for most commands is to 
   process the given directories, as well
   as all subdirs within them. specify
   -nosub to disable this.

options
   -nosub        do not include files in 
                 subdirectories.
   -nobin[ary]   skip binary files.
   -case         case-sensitive text 
                 comparison. default is
                 case-insensitive
                 comparison for all -text
                 strings, but NOT for -bin
                 blocks. case-sensitive
                 comparison is faster then
                 case-insensitive. for
                 further details type: sfk
                 help nocase
   -nocase       force case-insensitive 
                 comparison ALSO on -bin
                 patterns.
   -pat          starts a list of search or 
                 replace patterns of the
                 form xsrcxdstx where x is
                 the separator char, src
                 the source to search for,
                 and dst the destination to
                 replace it with. e.g. /foo/
                 bar/ or _foo_bar_ both
                 replace foo by bar. -pat
                 is not required if a
                 single filename is given.
   -text         the same as -pat, starting 
                 a text pattern list.
   -spat         same as -pat but also 
                 activates slash patterns
                 like \t . type "sfk help
                 pat" for the list of
                 possible patterns.
   -spats[trict] same as -spat, but stops 
                          with error on
                          undefined
                 slash patterns like \m in 
                 C:\myproj. every slash
                 must then be escaped, e.g.
                 using C:\\myproj.
   -bin[ary]     starts a list of binary 
                 replace patterns,
                 specified as hexcode like /
                 0A0D/2020/
   -bylist x.txt read search patterns from 
    a file x.txt, supporting
                 multiple lines per pattern.
                 (add -full for more.)
   -bylinelist x read /from/to/ or just 
    /from/ patterns from a file x
                 with one pattern per line. 
                 (add -full for more.)
                 -by(line)list does not
                 support sfk variables. to
                 use variables in patterns
                 create an sfk script with
                 patterns as parameters.
                 "sfk script" for more.
   -recsize      with same length 
                 replacements: set input
                 record size for processing
                 (default=100k)
   -firsthit     process only first found 
                 pattern match per file.
   -maxscan=nm   stop searching after 
                 (approximately) first n
                 megabytes per file. can be
                 used only with same length
                 replace.
   -quiet        do not show progress infos.
   -stat         show statistics like hits 
                 per pattern and no. of
                 files.
   -perf         show performance 
                 statistics.
   -memlimit=nm  with different-length 
                 replacements, files must
                 be loaded into memory for
                 processing. the default
                 limit for memory use is
                 300 MB. set -memlimit=500m
                 to select 500 MB.
   -full         print full help text 
                 telling about -bylist
                 pattern files, special
                 character case sensitivity
                 and nested or repeated
                 replace behaviour.

output options
   -dump         create hexdump of search 
                 hits or replaced text.
    -wide        with -dump: show 16 bytes 
                       per line.
    -lean        with -dump: show  8 bytes 
                       per line.
   -dumpfrom     always dump search hits 
                 but not replaced text.
   -dumpall      dump search text and 
                 replaced text.
   -nodump       do not create a hexdump, 
                 list only matching files.
   -astext       no hexdump, but print 
                 search hits as plain text.
                 use this only with plain
                 text files, not binary.
   -showle       highlight CR/LF line 
                 endings in hex dump output
   -context=n    with hexdump: show 
                 additional n bytes of
                 context.
   -reldist      with hexdump: tell 
                 relative distances to
                 previous hits.
   -to dir\$file write output files to 
    given path. for details about
                 output file masks, type 
                 "sfk help opt" or "sfk
                 run".
   -tofile x     write output data to a 
                 single output filename x
                 (which is not interpreted
                 as a mask but taken as is).
                 
   -more[n]      pause output every 30 or n 
                 lines.

return codes for batch files
   0 = no matches, 1 = matches found, >1 
   = major error occurred. see also "sfk
   help opt" on how to influence error
   processing.

about nested replacement patterns
   sfk replace myfile.dat /foo/bar/ 
   /bar/goo/ with SFK base, "foo" will be
   replaced by "bar" and then immediately
   "bar" is replaced again by "goo". with
   SFK Plus or XE, a replaced part of text
   is not replaced again in the same
   command, so "foo" stays replaced by
   "bar".

unexpected repeat replace behaviour
   depending on the input data and 
   search/replace expressions, it can
   happen that running the same replace
   multiple times on the same file produces
   further hits that didn't exist in the
   first run. add option -full to read more
   on this.

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

performance notice
   the system may cache output file(s), 
   writing to disk in background after sfk
   has finished. subsequent batch file
   commands may execute slower.

office file support
   sfk ofind        search in .xml text 
                      file contents of
                    office files like .docx 
                    .xlsx .ods .odt.
   sfk help office  for more infos and 
                    options

see also
   --- open source commands ---
   sfk xfind     search  wildcard text in 
                         plain text files
   sfk ofind     search  in office files  
                         .docx .xlsx .ods
   sfk xfindbin  search  wildcard text in 
                         text/binary
                         files
   sfk xhexfind  search  in text/binary 
                         with hex dump
                         output
   sfk extract   extract wildcard data 
                 from text/binary files
   sfk filter    filter  and edit text 
                 with simple wildcards
   sfk find      search  fixed    text in 
                         text
                         files
   sfk findbin   search  fixed    text in 
                         text/binary
                         files
   sfk hexfind   search  fixed    text in 
                         binary
                         files
   sfk replace   replace fixed    text in 
                 text/binary files
   --- freeware commands ---
   sfk view      GUI tool to search text 
                 as you type
   --- xe commercial commands ---
   sfk replace   replace fixed    text 
                 with high performance
   sfk xreplace  replace wildcard text in 
                 text/binary files
   sfk help xe   about SFK XE and 
                 xreplace with SFK
                 Expressions.

beware of Shell Command Characters.
   to find or replace text patterns 
   containing spaces or special
   characters like <>|!&?* you
   must add quotes "" around parameters
   or the shell environment will destroy
   your command. for example, pattern /
   foo bar/other/ must be written like "/
   foo bar/other/" within a .bat or .cmd
   file the percent % must be escaped
   like %% even within quotes: sfk echo
   -spat "percent %% is a percent \x25"

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

common usage errors
   sfk hexfind in.txt "/foo\r\n/"
      will not find "foo" at line ends, but 
      searches literal strings like "slash
      and r". add option -spat to enable
      slash patterns, converting \r\n to
      real CRLF codes, or use xhexfind
      where slash patterns are default.
   sfk hexfind mydir "/foo*bar/"
      will not find "foo" and "bar" with 
      any characters inbetween, but
      searches a literal star "*". use
      xhexfind to enable search with
      wildcards.
   sfk rep in.txt "/foo[0.1000 
   bytes]bar/---/"
      will not replace up to 1000 bytes 
      between "foo" and "bar", but replaces
      a literal string "foo" then "[1000
      bytes]" then "bar". use xed or
      xreplace instead.

examples
   sfk replace myfile.dat "/Lemon/Curry/"
      replace Lemon by Curry within 
      myfile.dat. search is
      case-insensitive, therefore "lemon"
      will be replaced as well. the quotes
      "" are optional here.
   sfk replace -pat /FooCase// -dir . 
                 -file .txt
      search for FooCase in all .txt files 
      below current directory. note that if
      you leave out the single fileOrDir
      parameter, you have to say -[s]pat,
      -bin or -text first to tell clearly
      that you will specify the target
      fileset later on.
   sfk rep -spat "/The foo/The\tbar/" -dir 
             mydocs
      replaces "The foo" by "The" and "bar" 
      separated by TAB char, within all
      files within mydocs.
   sfk rep -binary /1A/20/ -dir docs -file 
                             .txt .info .
                             note
      replaces all bytes with code 0x1A by 
      code 0x20, in all .txt, .info and .
      note files, in directory docs and all
      subdirectories.
   sfk replace tmp\image.dat -bylist 
   patches.txt
      searches for source patterns in file 
      tmp\image.dat, replaces by patterns
      specified in patches.txt
   SFK Base and XE: swap text in two steps
   sfk -yes rep io.txt /foo34/foo99/ 
         /foo12/foo34/ +rep /foo99/foo12/
      replaces foo12 by foo34 and vice 
      versa. with SFK Base, a word which is
      replaced may be replaced again by a
      following pattern, therefore the
      intermediate step: turn foo34 into
      something not used anywhere in io.txt,
      then replace foo12, then replace the
      intermediate pattern back in a second
      replace command on the same file.
   SFK XE only: swap text in one step
   sfk rep io.txt /foo12/foo34/ 
   /foo34/foo12/ -yes
      replaces foo12 by foo34 and vice 
      versa. with XE, a word which is
      replaced is not looked at again in
      the same command, so "foo34" from the
      first pattern is not changed by the
      2nd.
   sfk hexfind mydir -pat /FooCase/ +list 
                       -late
      do not replace, just find binary 
      files containing "FooCase", then list
      them sorted by time. also accepts
      -bylist files.
   sfk replace -binary /666f6f/626172/ 
                 -dir mydir -file .dat
      replace binary data with hex values 
      0x66, 0x6f, 0x6f by data with values
      0x62, 0x61, 0x72 in all .dat files.
 
example with output: preparing a replacement of pattern "class Foo". sfk rep testfiles "/class foo/class Other/" -dump output: [simulating:] [total hits/matching patterns/non-matching patterns] testfiles\FooBank\GUI\include\ FooGUI.hpp: hit at offset 0x64 >6F6E616C 6974792E< onality. 00000054 >0D0A2A2F 0D0A0D0A< ..*/.... 0000005C >636C6173 7320466F< class Fo 00000064 >6F475549 0D0A7B0D< oGUI..{. 0000006C >0A707562 6C69633A< .public: 00000074 [001/1/0] testfiles\FooBank\GUI\ include\FooGUI.hpp testfiles\ Formats\12-foo-jam.txt: hit at offset 0xE6C >6F6E616C 6974792E< onality. 00000E5C >0D0A2A2F 0D0A0D0A< ..*/.... 00000E64 >636C6173 7320466F< class Fo 00000E6C >6F475549 0D0A7B0D< oGUI..{. 00000E74 >0A707562 6C69633A< .public: 00000E7C [001/1/0] testfiles\Formats\ 12-foo-jam.txt 38 files checked, 2 would be changed. [add -yes to execute.] the input data is listed as hex and ascii, with the hits highlighted.

you are viewing this page in mobile portrait mode with a limited layout. turn your device right, use a desktop browser or buy the sfk e-book for improved reading.

 
sfk is a free open-source tool, running instantly without installation efforts. no DLL's, no registry changes - just get sfk.exe from the zip package and use it (binaries for windows, linux and mac are included).

 

the Endless Image 🍣 Sushi