I have a simple bash script where I generate some temporary files using split, do some processing and then try to track down all the files at the end and merge them
rand_int=$RANDOM
split -d -l $n_lines_split $1 $rand_int   #works fine
for f in $(find . -amin -200 -regex '.*$rand_int.*' ); do 
    (some processing here) ; 
done
My problem is that in the find command $rand_int is interpreted literally, whereas I want to use the variable's value.
In the shell, single-quotes (') cause what's inside to be interpreted literally. What you want to do is use double-quotes (") around the expression with $rand_int.
So for the find expression:
find . -amin -200 -regex ".*$rand_int.*"
                        use " " instead of ''
for f in $(find . -amin -200 -regex ".*$rand_int.*" ); do 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With