Get character position within variable

Hi all

let's say i have a file named 1234_v2_abcd
i need to find the position of the character located after _v, in above case this would be character number 2
the count of the characters before _v can change, but i always have a number after _v

can anybody help :slight_smile:

echo 1234_v2_abcd | perl -lne 'print(index($_, "_v")+2)'

Or if +3 if you count position from 1.

1 Like

thank you! works perfect

expr 1234_v2_abcd : '.*_v.'
1 Like

binlib,

thank you for your reply, your solution also works fine!