Skip to content

Latest commit

 

History

History
39 lines (24 loc) · 840 Bytes

replace.md

File metadata and controls

39 lines (24 loc) · 840 Bytes

string replace OLD NEW [STRING]

This command will return the replace the OLD value with NEW for the STRING.

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 replace "friendly" "enemies" "The people were friendly"

Would return The people were enemies

    string replace "tomato" "ememies" "The people were friendly"

Would return The people were friendly

Piping content

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

    echo "The people were friendly" | string -nl -i - replace "friendly" "enemies"

Would return The people were enemies

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

Would return The people were friendly