hello,
is the test with [[ ... && .... ]] the only way here? how should look test with "-a" [ .... -a .....] in case of pattern test + file test as in example below?
is the test with [[ ... && .... ]] the only way here? how should look test with "-a" [ .... -a .....] in case of pattern test + file test as in example below?
Code:
$ A=/tmp/abcd
$ [[ "${A}" = /tmp/* ]] && echo pat ok || echo pat not ok
pat ok
$ A=/tm/abcd
$ [[ "${A}" = /tmp/* ]] && echo pat ok || echo pat not ok
pat not ok
$ A=/tmp/abcd
$ ls /tmp/abcd
ls: 0653-341 The file /tmp/abcd does not exist.
$ [[ "${A}" = /tmp/* [COLOR=#CC0000]-a[/color] ! -e "${A}" ]] && echo pat ok and file not exists || echo pat not ok and/or file exists
ksh: 0403-057 Syntax error: `-a' is not expected. [COLOR=#CC0000]<--- error[/color]
$ [[ "${A}" = /tmp/* [COLOR=#CC0000]&[/color] ! -e "${A}" ]] && echo pat ok and file not exists || echo pat not ok and/or file exists
ksh: 0403-057 Syntax error: `&' is not expected. [COLOR=#CC0000]<--- error[/color]
$ [[ "${A}" = /tmp/* [COLOR=#CC0000]&&[/color] ! -e "${A}" ]] && echo pat ok and file not exists || echo pat not ok and/or file exists
pat ok and file not exists [COLOR=#CC0000]<--- ok[/color]
$ touch /tmp/abcd
$ [[ "${A}" = /tmp/* && ! -e "${A}" ]] && echo pat ok and file not exists || echo pat not ok and/or file exists
pat not ok and/or file exists [COLOR=#CC0000]<--- error[/color]