more run.sh
!/bin/bash
input="data.txt"
while IFS= read -r var
do
startdir="/web/logs"
searchterm=$(echo $var | awk -F'=' '{print $1}')
replaceterm=$(echo $var | awk -F'=' '{print $2}')
find "$startdir" -type f -exec grep -l "$searchterm" {} + |
while read file
do if sed -e "s#$searchterm#$replaceterm#g" "$file" > /tmp/tempfile.tmp
then mv /tmp/tempfile.tmp "$file"
printf "Modified: %s\n" "$file"
fi
done
rm -f /tmp/tempfile.tmp
done < "$input"
echo "*** Yay! All Done! ***"
When data.txt has the below entry the run.sh
works fine
more data.txt
yellow=hello
But, when I change the data.txt entry as below run.sh
fails
more data.txt
10.112.34.5=102.3.12.43
run.sh fails with the below fork
error.
bash-3.2$ ./run.sh.sh
./replacestring.sh: line 1: !/bin/bash: No such file or directory
./replacestring.sh: fork: Not enough space
*** Yay! All Done! ***
uname -a
SunOS mymac 5.10 Generic_150400-26 sun4v sparc sun4v
Why i m getting fork error when i change entries in data.txt?
What is the fix ?
Any help will be appreciated.