Sorry for bumpy topic name (feel free to edit if you find more fitting title after looking at problem). Code sample equals 1000 words, so here we go:
if [ "$REGEX" != "" ]; then
find $TEST_DIR -type f -regextype posix-extended -regex '^.*(status|stderr|stdout)-captured$' |
grep -E $REGEX |
awk '{print(""$1" "$1)}' | sed 's/-captured$/-expected/' |
while read -r line; do mv -f $line; done
else
find $TEST_DIR -type f -regextype posix-extended -regex '^.*(status|stderr|stdout)-captured$' |
awk '{print(""$1" "$1)}' | sed 's/-captured$/-expected/' |
while read -r line; do mv -f $line; done
fi
What code does is not all that important, I'd just like to find more elegant way to either use "grep -E $REGEX" or not. I thought that conditdonal aliases could do the job just like I'm used to from shell usage, but they does not work inside scripts.
I could put in a condition, but I fear performance impact from multiple evaluations.
Any way to make the code "more elegant"?