I have the following script..but it does not seem to work just the way I want it:
The first grep statment returns more records then I need
because I am only looking for patterns such as 127.10.1.2
but it returns stuff such as 1.1.1.1.2
so the the second grep statement is my attempt at fixing the problem...but it does not return anything.
Can somebody spot the problem? I am Sun Solaris.
Thanks.
Code:
#!/bin/bash
find . -type f | while read fname; do
grep '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' "$fname"
#grep '\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}' "$fname"
if [ $? -eq 0 ]; then
echo "The above matches came from: $fname"
fi
done;
The first grep statment returns more records then I need
because I am only looking for patterns such as 127.10.1.2
but it returns stuff such as 1.1.1.1.2
so the the second grep statement is my attempt at fixing the problem...but it does not return anything.
Can somebody spot the problem? I am Sun Solaris.
Thanks.