Caltech Library logo

USAGE

string [OPTIONS] [ACTION] [ACTION PARAMETERS...]

SYNOPSIS

string is a command line tool for transforming strings in common ways.

OPTIONS

Options are shared between all actions and must precede the action on the command line.

    -d, -delimiter           set the delimiter
    -do, -output-delimiter   set the output delimiter
    -e, -examples            display examples
    -generate-markdown-docs  output documentation in Markdown
    -h, -help                display help
    -i, -input               input file name
    -l, -license             display license
    -nl, -newline            if true add a trailing newline
    -o, -output              output file name
    -quiet                   suppress error messages
    -v, -version             display version

ACTIONS

    contains       has substrings: SUBSTRING [STRING]
    count          count substrings: SUBSTRING [STRING]
    englishtitle   English style title case: [STRING]
    hasprefix      true/false on prefix: PREFIX [STRING]
    hassuffix      true/false on suffix: SUFFIX [STRING]
    join           join JSON array into string: DELIMITER [JSON_ARRAY]
    length         length of string: [STRING]
    padleft        left pad: PADDING MAX_LENGTH [STRING]
    padright       right pad: PADDING MAX_LENGTH [STRING]
    position       position of substring: SUBSTRING [STRING]
    replace        replace: OLD NEW [STRING]
    replacen       replace n times: OLD NEW N [STRING]
    slice          copy a substring: START END [STRING]
    split          split into a JSON array: DELIMITER [STRING]
    splitn         split into an N length JSON array: DELIMITER N [STRING]
    tolower        to lower case: [STRING]
    totitle        to title case: [STRING]
    toupper        to upper case: [STRING]
    trim           trim (beginning and end), CUTSET [STRING]
    trimleft       left trim: CUTSET [STRING]
    trimprefix     trims prefix: PREFIX [STRING]
    trimright      right trim: CUTSET [STRING]
    trimspace      trim leading and trailing spaces: [STRING]
    trimsuffix     trim suffix: SUFFIX [STRING]

EXAMPLES

Convert text to upper case

string toupper "one"

Convert text to lower case

string tolower "ONE"

Captialize an English phrase

string englishtitle "one more thing to know"

Split a space newline delimited list of words into a JSON array

string -i wordlist.txt split "\n"

Join a JSON array of strings into a newline delimited list

string join '\n' '["one","two","three","four","five"]'

Related: contains, count, englishtitle, hasprefix, hassuffix, join, length, padleft, padright, position, replace, replacen, slice, split, splitn, tolower, totitle, toupper, trim, trimleft, trimprefix, trimright, trimspace, trimsuffix

string v0.0.20-pre