# ffind Utility

Topics
Usage | Compiling

Usage

The ffind text utility is a console-based program used to search for, insert, and replace strings in text files. You can pass one of several switches to the program from the command line to perform any one of the available operations. From the command line you can use a wildcard to specify a group of files, for example: *.txt would process all files in the current directory that have a .txt extension. For a list of switches, execute the program with no arguments.

    ffind program version 1031.101
    Usage: ffind [switches] iofile.txt
    Switches:
              -a = Do not append lines connected by a backslash
              -c = Concatenate file to stdout.
              -f = Find first occurrence of specified string: -f"string"
              -F = Find all occurrences of specified string: -F"string"
              -i = Perform case insensitive compare.

              -R -W = Replace all occurrences of a string in a file.
              Usage: -R"string" -W"replacement"

              -L -W = Replace entire line after the specifed string.
              Usage: -L"string" -W"replacement"

              -I -W = Insert a line after the specifed string.
              Usage: -I"string" -W"insert"

The "-a" switch will cause each line of a long line of text connected by a series of backslashes to be treated as a single line.

The "-c" switch is used print a text file to the console.

The "-f" switch is used to find the first occurrence of the specified string on each line of the file.

The "-F" switch is used to find all occurrences of the specified string in the text file. At the completion of the find operation the total number of strings found will be passed to the operating system.

The "-i" switch is used to perform a case-insensitive comparison during a search or replacement operation.

The "-R -W" switches are used to replace all occurrences of a string in a text file. The -R switch specifies the string that will be replaced. The -W switch specifies the string to insert in place of the string specified by the -R switch. At the completion of the replace operation the total number of strings replaced will be passed to the operating system.

The "-L -W" switches are used to replace a line of text after the specified string. The -L switch specifies the point were the line will be truncated. The -W switch specifies the line of text to insert after the string specified by the -L switch. At the completion of the line replace operation the total number of lines inserted will be passed to the operating system.

The "-I -W" switches are used to insert a string after the specified string. The -I switch specifies the point were the new string will be inserted. The -W switch specifies the string to insert after the string specified by the -I switch. At the completion of the insert operation the total number of string inserted will be passed to the operating system.

Compiling

Console Base Utility Program

:
Four makefiles are provided in the "utils" directory to compile the source code on one of four different compilers.

    "msvc40.mak"  - Makefile for Microsoft visual C/C++ 4.2
    "djgpp.mak"   - Makefile for DJGPP gcc 2.7.2.1
    "gnu_gcc.mak" - Makefile for GNU g++ 2.7.2.1
    "hpux10.mak"  - Makefile for HPUX C++ A.10.24

Building the Executable:

To compile use the "make -f" option followed by the makefile name. To compile using MSVC use the "nmake -f" option. The resulting executable will be named after the name set by the PROJECT macro in the makefile. By default the program will be named "ffind" under UNIX or "ffind.exe" under Windows 95/DOS.

Removing the Object Files and the Executable:

To remove the object files and the executable use the "make -f" option followed by the makefile name, followed by "clean": make -f hpux10.mak clean

Under MSVC use the "nmake -f" option followed by the makefile name, followed by "clean": nmake -f msvc40.mak clean

End Of Document