I have this code so far:
#!/bin/bash
list=$(find "$(dirname "$0")/../temp/" -regex "(part.[a-z])")
echo "$list"
I want to find all files in the temp
directory that have a file name like this:
part.aa
part.ab
part.aaa
part.qqk
current path is:
./scripts/script.sh
path where files are in:
../temp
Ideally, the result stored in list should be in a form that allow looping over it line by line.
The regex must match the whole path.
Note that
.
is special in regexes, it matches any character. To match a literal dot, you need to backslash it (or use[.]
).