Thanks for the help but I still have the problem of the if statement always being true. This time I enclosed the file so you can test it.

Gary R

On 8/4/21 5:04 PM, Greg Wooledge wrote:
On Wed, Aug 04, 2021 at 04:58:00PM -0700, Gary L. Roach wrote:
Path="/Test/gary/run/something"
IFS=/
read -a Array <<< $Path
You're setting IFS permanently for the whole script.  It's usually better
to set it only for the duration of the single read command which uses
it.  Also, read should always be used with the -r option, unless you want
backslash mangling to occur.

IFS=/ read -ra Array <<< "$Path"

         if [ A="0 ; " ]
This is incorrect, at least twice over.  You need to separate each of
the arguments of the [ command with whitespace.

if [ A = "0 ; " ]

It helps if you remember that [ is simply a fancy synonym for the test
command.  A more natural way to write this would be

if test A = "0 ; "

Next, you are comparing two constant strings, "A" and "0 ; ".  This
comparison is not useful, because they are always different strings.
If A is a variable, then you probably meant to write this:

if [ "$A" = "0 ; " ]

Attachment: testing.sh
Description: application/shellscript

Reply via email to