Skip to content

Latest commit

 

History

History
39 lines (24 loc) · 790 Bytes

position.md

File metadata and controls

39 lines (24 loc) · 790 Bytes

string position TARGET [STRING]

This command will return the position (where zero is the first position) of TARGET in STRING. If the TARGET is not found a negative 1 will be returned.

Typical command line

NOTE: we'll use the option -nl to append a new line to the output and make it easier to read.

    string -nl position "friend" "The people were friendly"

Would return 16

    string position "tomato" "The people were friendly"

Would return -1

Piping content

NOTE: To read content from standard input we use the -i - option.

    echo "The people were friendly" | string -nl -i - position "friend"

Would return 16

    echo "The people were friendly" | string -nl -i - position "apple"

Would return -1