S
S
shnicel2016-03-02 23:45:32
bash
shnicel, 2016-03-02 23:45:32

Why is the variable after the regular expression empty?

I want to cut /img_test/f15/ from here /home/admin/web/ovcvs4ds.fvds.ru/public_html/img_test/f15/f1578e58f50e5d4cb081c10a827eac71.png in this way

FINALFOLDER=$(find $CURRENT_IMAGE -regextype posix-extended -regex '\/img_test\/.*\/')
echo "$FINALFOLDER"

but everything is empty in the console, why?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xotkot, 2016-03-03
@shnicel

$ CURRENT_IMAGE="/home/admin/web/ovcvs4ds.fvds.ru/public_html/img_test/f15/f1578e58f50e5d4cb081c10a827eac71.png"
$ echo $CURRENT_IMAGE | grep -o -e '\/img_test\/.*\/' 
/img_test/f15/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question