I have a for loop in my bash script.
for dir in $directories
do
dockerfile=$(find ./repo/$dir -name "Dockerfile");
docker build -f $dockerfile . -t $dir:version;
new_image=$(echo "$dir:version" | cut -d '/' -f2);
done
How can I pass $new_image
output to another variable?
If I do something like this
new_image=$(echo "$image:version" | cut -d '/' -f2 >> list_images.txt)
I get the list of docker images in my .txt file but is there a way to pass the output to a variable? And update that variable value on each iteration?
The expected output after one iteration is something like
testing1:version
So when the for loop stops executing I get something like this in my .txt file.
testing1:version
kubernetes:version
node:version
And this is what I need, I can't figure out a better way to do this.