GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
text-block(1) FreeBSD General Commands Manual text-block(1)

text-blockreads text from standard input or given file, and writes it to standard output or a given file. On the text, various modifications can be applied, according to the operation mode.

text-block [-C | --cat] [OPTIONS]

text-block [-0 | --discard] [OPTIONS]

text-block [-H | --highlight] [OPTIONS]

text-block [-E | --enumerate] [OPTIONS]

text-block [-X | --extract] [OPTIONS]

text-block [-D | --delete | --remove] [OPTIONS]

text-block [-F insert_file | --insert-front insert_file] [OPTIONS]

text-block [-B insert_file | --insert-back insert_file] [OPTIONS]

text-block [-R insert_file | --replace insert_file] [OPTIONS]

text-block [-h | --help]

text-block [-v | --version]


OPTIONS: [-b begin_tag | --begin-tag begin_tag] [-e end_tag | --end-tag end_tag] [-i | --input input_file] [-o | --output output_file] [-a | --append] [-p | --in-place] [-k | --keep-broken] [-m | --min-actions] [-M | --max-actions] [-s | --select from_line to_line] [-b | --begin-tag begin_tag] [-e | --end-tag end_tag] [-t | --tag tag] [-y | --include-tags] [-x | --exclude-tags] [-f | --full-tag-lines] [-g | --tags-only] [-q | --suppress-warnings] [--enumerate-format format] [--enumerate-label1 string] [--enumerate-label2 string] [--highlight-begin string] [--highlight-end string] [--highlight-unmarked1 string] [--highlight-unmarked2 string] [--highlight-marked1 string] [--highlight-marked2 string] [--highlight-param begin_label end_label unmarked1_label unmarked2_label marked1_label marked2_label]

text-blockreads text from standard input or given file, and writes it to standard output or a given file. On the text, various modifications can be applied, according to the operation mode:

  • Cat: copy the input text as-is.
  • Discard: do nothing (i.e. just discard the input).
  • Enumerate: add line numbers. The format of the enumeration is configurable.
  • Highlight: visually highlight text block between markers. The format of the marking is configurable, e.g. to apply ANSI colouring, etc.
  • Delete: remove text between markers.
  • Insert Front: insert text from a file at front of marked blocks.
  • Insert Back: insert text from a file at back of marked blocks.
  • Replace: replace text of marked blocks by text from a file.

The marking used for the operation modes is based on configurable begin and end tags, e.g. <BEGIN-OF-BLOCK> and <END-OF-BLOCK>, or BEGIN and END. The handling of tags is configurable:

  • tags-only: Only the text between the marker tags belongs to a block. That is, multiple blocks can appear on the same line. This is the default.
  • full-tag-lines: A marker includes the full line of is begin and end tags. That is, a line containing a begin/end tag is handled like being the begin/end tag. This also means that only the first tag in a line is handled. All further tags in the same line are ignored! Hint: Use Highlight mode to visualise the behaviour.

Furthermore, the handling of begin/end tags is configurable as well:

  • exclude-tags: Marked text does not include the begin/end tags. This is the default.
  • include-tags: Marked text includes the begin/end tags.

A special case is to have identical begin/end tags, e.g. <MARKER>. The text block "inside" this tag is therefore always empty. A use case for such a marker is e.g. to mark where to insert the contents of a file.

Alternatively to marking by tags, the marking can be based on a line number range selection. Negative line numbers denote counting backwards from the end of the file, which in this case needs to be line-counted first. That is, input from standard input is not possible in this case.

The following options are available:

|
Run in Cat mode (default).
|
Run in Discard mode.
|
Run in Highlight mode.
|
Run in Enumerate mode.
|
Run in Highlight mode.
| |
Run in Delete mode.
insert_file | insert_file
Run in Insert-Front mode. "-" is placeholder for inserting from standard input. In this case, an input file is required.
insert_file | insert_file
Run in Insert-Back mode. "-" is placeholder for inserting from standard input. In this case, an input file is required.
insert_file | insert_file
Run in Replace mode. "-" is placeholder for replacing from standard input. In this case, an input file is required.
|
Prints command-line parameters.
|
Prints program version.
| from_line to_line
Select a line range, ranging from line from_line to line to_line. A from_line of one (1) denotes marking from start of the file. A to_line of zero (0) denotes marking until end of the file. If a line number is negative, it is counted backwards from the end of the file. This requires an input file (--input|-i), which is line-counted first. Line range selection is mutually exclusive with tags (--begin-tag|-b|--end-tag|--tag|-t).
begin_tag | begin_tag
Sets the begin tag. Tags are mutually exclusive with line selection (--select|-s).
end_tag | end_tag
Sets the end tag. Tags are mutually exclusive with line selection (--select|-s).
tag | tag
Sets a combined begin/end tag, i.e. the tag marks begin and end. Tags are mutually exclusive with line selection (--select|-s).
| input_file
Sets the input file. "-" is placeholder for reading from standard input (default).
| output_file
Sets the output file. By default, an existing output file will be overwritten. "-" is placeholder for writing to standard output (default)
|
Opens the output file in append mode, appending new output instead of overwriting an existing file.
|
In-place update into the input file. The output is written to a temporary file with extension "~" first, which replaces the input file on success.
|
Keep broken output in case of error (default: off). [-m | --min-actions] Set lower limit for number of marking actions. If the number of applied markings falls below this limit, an error is returned. [-M | --max-actions] Set lower limit for number of marking actions. If the number of applied markings exceeds this limit, an error is returned.
|
Include the marker tags in the marking. Hint: Use Highlight mode to visualise the behaviour.
|
Exclude the marker tags from the marking. Hint: Use Highlight mode to visualise the behaviour.
|
Include full marker tag lines in the marking. Hint: Use Highlight mode to visualise the behaviour.
|
Exclude the marker tag lines from the marking. Hint: Use Highlight mode to visualise the behaviour.
|
Suppress warnings on useless input parameters. Useful for debugging.
format
In Enumerate mode, sets the format of the line number output according to printf formatting. However, only the number format specification is allowed here. Examples:
  • 06 -> add leading zero to get a 6-digit output (e.g. "000001", etc.). This is the default.
  • 4 -> 4-digit line numbers, prepended with space when necessary (e.g. " 2", etc.).
  • -4 -> left-adjusted 4-digit number (e.g. "3 ").
string
For Enumerate mode: prepends the given string before the line number output. Default: $'\x1b[36m' (enables cyan colour output).
string
For Enumerate mode: appends the given string before the line number output. Default: $'\x1b[0m ' (disables colour output, and add a space).
string
For Highlight mode: Sets string to visualise the begin of a marked block. Default: ⭐.
string
For Highlight mode: Sets string to visualise the end of a marked block. Default: 🛑.
string
For Highlight mode: Sets string to visualise the begin of an unmarked text fragment. Default: $'\x1b[34m' (enables blue colour output).
string
For Highlight mode: Sets string to visualise the end of an unmarked text fragment. Default: $'\x1b[0m ' (disables colour output).
string
For Highlight mode: Sets string to visualise the begin of a marked text fragment. Default: $'\x1b[31m' (enables red colour output).
string
For Highlight mode: Sets string to visualise the end of a marked text fragment. Default: $'\x1b[0m ' (disables colour output).
begin_label end_label unmarked1_label unmarked2_label marked1_label marked2_label
A shortcut to set all 6 highlight parameters at once.

Note: the example input files example1.txt, example2.txt, insert.txt, and numbers.txt, referred to in the following command-line examples, are usually installed under /usr/share/text-block or /usr/local/share/text-block/!

  • text-block -i example1.txt --cat
  • text-block -i /etc/system-info.d/01-example
  • text-block -i /etc/system-info.d/01-example -C

  • text-block -i example1.txt --enumerate
  • figlet "Test!" | text-block -E
  • text-block -i /etc/system-info.d/01-example -E
  • text-block -i /etc/system-info.d/01-example --enumerate --enumerate-format "6" --enumerate-label1 $'\x1b[37m<' --enumerate-label2 $'>\x1b[0m '

  • text-block -i example1.txt -b '<BEGIN-BLOCK>' -e '<END-BLOCK>' --highlight
  • text-block -i example1.txt -b '<BEGIN-BLOCK>' -e '<END-BLOCK>' -H --exclude-tags --tags-only
  • text-block -i example1.txt -b '<BEGIN-BLOCK>' -e '<END-BLOCK>' -H --include-tags --tags-only
  • text-block -i example1.txt -b '<BEGIN-BLOCK>' -e '<END-BLOCK>' -H --include-tags --full-tag-lines
  • text-block -i example1.txt -b '<BEGIN-BLOCK>' -e '<END-BLOCK>' -H --exclude-tags --full-tag-lines
  • text-block -i example2.txt -b '<MARKER>' -H --exclude-tags --tags-only
  • text-block -i example2.txt -b '<MARKER>' -H --include-tags --tags-only
  • text-block -i example2.txt -b '<MARKER>' -H --include-tags --full-tag-lines
  • text-block -i example2.txt -b '<MARKER>' -H --exclude-tags --full-tag-lines
  • text-block -i example1.txt -b '<BEGIN-BLOCK>' -e '<END-BLOCK>' --highlight --highlight-param "☀" "🌙" $'\[32m' $'\[0m' $'\[31;5m' $'\[0m'
  • text-block -i numbers.txt --select 1 3 -H
  • text-block -i numbers.txt --select -3 -1 -H
  • text-block -i numbers.txt --select -5 0 -H

  • text-block -i example1.txt -b '<BEGIN-BLOCK>' -e '<END-BLOCK>' --delete
  • text-block -i example1.txt -b '<BEGIN-BLOCK>' -e '<END-BLOCK>' -D
  • text-block -i numbers.txt --select 2 4 -D
  • text-block -i numbers.txt --select -4 -2 -D
  • text-block -i numbers.txt -s -7 0 -D

  • text-block -i example1.txt -b '<BEGIN-BLOCK>' -e '<END-BLOCK>' --insert-front insert.txt
  • text-block -i example1.txt -b '<BEGIN-BLOCK>' -e '<END-BLOCK>' -F insert.txt
  • text-block -i example1.txt -b '<BEGIN-BLOCK>' -e '<END-BLOCK>' -F insert.txt -f
  • text-block -i example1.txt -b '<BEGIN-BLOCK>' -e '<END-BLOCK>' -F insert.txt --min-actions 1 --max-actions 1
  • text-block -i example1.txt -b '<BEGIN-BLOCK>' -e '<END-BLOCK>' -F insert.txt -m 1 -M 1
  • text-block -i numbers.txt -F insert.txt --select 4 7
  • text-block -i numbers.txt -F insert.txt --select -4 -2
  • text-block -i numbers.txt -F insert.txt -s 4 0

  • text-block -i example1.txt -b '<BEGIN-BLOCK>' -e '<END-BLOCK>' --insert-back insert.txt
  • text-block -i example1.txt -b '<BEGIN-BLOCK>' -e '<END-BLOCK>' -B insert.txt
  • text-block -i example1.txt -b '<BEGIN-BLOCK>' -e '<END-BLOCK>' -B insert.txt -f
  • text-block -i example1.txt -b '<BEGIN-BLOCK>' -e '<END-BLOCK>' -B insert.txt --min-actions 1 --max-actions 1
  • text-block -i example1.txt -b '<BEGIN-BLOCK>' -e '<END-BLOCK>' -B insert.txt -m 1 -M 1
  • text-block -i numbers.txt -B insert.txt --select 4 7
  • text-block -i numbers.txt -B insert.txt --select -4 -2
  • text-block -i numbers.txt -B insert.txt -s 4 0

  • text-block -i example1.txt -b '<BEGIN-BLOCK>' -e '<END-BLOCK>' --replace insert.txt
  • text-block -i example1.txt -b '<BEGIN-BLOCK>' -e '<END-BLOCK>' --replace insert.txt --include-tags
  • text-block -i example1.txt -b '<BEGIN-BLOCK>' -e '<END-BLOCK>' --replace insert.txt --include-tags --full-tag-lines
  • text-block -i example1.txt -b '<BEGIN-BLOCK>' -e '<END-BLOCK>' -R insert.txt -gy
  • text-block -i numbers.txt -R insert.txt --select 4 7
  • text-block -i numbers.txt -R insert.txt --select -4 -2
  • text-block -i numbers.txt -R insert.txt -s 4 0

  • text-block --help
  • text-block --version
  • text-block --v
May 11, 2025 text-block

Search for    or go to Top of page |  Section 1 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.