The script will post the length of all lines in all files, regardless of length. To find the lines longer than 2047 chars, try
Code:
#!/bin/sh
for file in "$@"; do
awk -v f=$file '{ if ( length( $0 ) > 2047 ) {
printf( "%s %5d: %s\n", f, length( $0 ), $0 );
}
}' $file
done
and invoke it as above.
If you have a newer version of
wc you can try
wc -L /vob/project/* (captial L) to show the length of the longest line in each file.
So, assuming your wc supports this,
Code:
#!/bin/sh
MAX_LINE=2047
TEMPFILE=/tmp/out.$$.txt
# first, create temp file with list of files + max line lengths
find . -type f -print | xargs wc -L | grep -v total >> ${TEMPFILE}
while read term
do
while read line
do
max_line=$(echo $line | awk '{print $1}')
filename=$(echo $line | awk '{print $2}')
if [ "$max_line" -lt "$MAX_LINE" ]; then
echo "$filename:" >> ~/$term.txt
grep -i "$term" $filename >> ~/$term.txt
fi
done < ${TEMPFILE}
done < search.strings
rm -f ${TEMPFILE}
Will do what you want, excluding any file from the search that contains a line longer than 2047 chars.
Cheers
ZB