bash convert find to array 1

bash convert find to array

array=( $(find blah blah) )

# loop over it
for i in ${array[@]}; do
    echo $i

Here is what the above code is Doing:
1. The first line is a comment.
2. The second line is a variable assignment. The variable is called array. The value of the variable is the output of the find command.
3. The third line is a for loop. The loop iterates over the elements of the array variable.
4. The fourth line is a command. The command is echo. The command is executed once for each element of the array.

Similar Posts