I would like each row generated by my command to be an element of an array but when I try to see how many elements are in my array, it tells me that there is only one.
#!/bin/bash
var=$(find "$1" 2>/dev/null)
echo "$var"
t=("$var")
echo "$t"
echo "${t[1]}"
echo "${#t[*]}"
In fact I would like to iterate on my elements. I tried another way but it doesn't work either :
#!/bin/bash
find "$1" 2>/dev/null | while read line
do
code_fichier=$(md5sum "$line" 2>/dev/null)
echo "$code_fichier" >> list_md5sum.txt 2> /dev/null
done
cat list_md5sum.txt | while read line
do
var=$(grep "$(echo "$line" | cut -f1 -d" ")" list_md5sum.txt)
echo "$var"
done
rm list_md5sum.txt
I want to have a grep on the line element only once but, by iterating, the grep is done several times (the number of lines there are in the file) but I don't see how to avoid that
I thank you for your help and wish you a good day