0

I am trying to find the file names in a path. Using following script, but getting issue when tries to put that name in a variable:

for file in "${PROJECT_DIR}/temp_namespaces"/*
do
    echo "${file##*/}"
    namespaces= "${file##*/}"
    echo "namespace = " > "${namespaces}"
done

it prints the file name from first echo, but after that both lines gives error:

namespaces= "${file##*/}"                ----   command not found
echo "namespace = " > "${namespaces}"    ----  No such file or directory

I am using linux available on amazon/aws-cli base image to run the above script.

I need to get the file names from a path and store them in a variable that will be used later in script to run few more commands.

Any pointers are appreciated.

Thanks

1 Answer 1

0

Strangely I found that script got fixed when removed space and quotes from following line:

namespaces= "${file##*/}"

and changed it as:

namespaces=${file##*/}

removing one space and quotes, that's all.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .