Thread: Matching strings in bash
i'm having nightmare understanding string matching in bash:
for neither love nor money, can't $filename:$i:1 match "l". i've tried single brackets (not entirely sure how differs), encapsulating variable in quotes, removing spaces (nor sure why spaces matter), , else can think of.code:#!/bin/bash #migrate.sh #0.01 test run filename=lolroflcopter_win.woot (( i=0; i<${#filename}; i++ )) if [[ $filename:$i:1 == l ]] echo "found blighter!" fi echo ${filename:$i:1} done
many google searches have resulted in various syntaxes, none of working in application. can tell me going wrong?
hi, try:
code:if [[ "${filename:i:1}" == "l" ]]
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] Matching strings in bash
Ubuntu
Comments
Post a Comment