Skip to content

Latest commit

 

History

History
12 lines (8 loc) · 440 Bytes

get-index-of-character-in-string.md

File metadata and controls

12 lines (8 loc) · 440 Bytes

Get index of character in string

Awk string functions operate on characters. To find the index of a character in a string, use index:

echo "test" | awk '{print index($0, "s")}'
# 3

This will return the integer location of the first occurence of the search string or zero if it is not found.

See String Functions in the manual.