my problem is the following: I have this bash script:
#!/bin/bash
IFSBAK=$IFS
if [ "$TXTEXT" = "" ];
then
CMD="find . -iname \"*.txt\" -or -iname \"*.text\""
else
CMDTEMP="find . "
IFS=":"
for i in $TXTEXT
do
CMDTEMP="${CMDTEMP} -iname \"*.${i}\" -or"
done
IFS=$IFSBAK
CMD=${CMDTEMP%-or}
fi
FILES=$(eval $CMD)
OUTPUT=$1
for f in $FILES
do
VAR=$(grep -ae [a-zA-Z0-9] "$f" | tr -cs "[:alnum:]" "\n")
IFS=$' \n\t-?=!*][.\",();\'\`\´:'
for v in $VAR
do
echo $v >> "${OUTPUT}"
done
IFS=$' \n\t'
done
and I need to insert this code inside a C program. I've tried to re-write the all script on a single line testing it directly with the shell and it works, but I'm having problems with quotes and escaping trying to use it as a parameter of the system() call. Can you suggest me a way out?
Thank you for your help