The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




Thread: grep wc
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 08-27-2007
rorey_breaker rorey_breaker is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 20
grep wc

Hello, I am trying add all occurances of the current user into an ouputfile in a numbered list e.g. 1 ) username......

I have a problem thou, the grep seach word count is not assigning a number to the lineno variable, this is a problem and I can not seem to get it to work with various brackets and speech marks. Please help this is very frustrating.

echo "What file to search? "
read file

int=1
echo "starting Grep"

lineno=grep $USER $file | wc -l
set -- `grep $USER $file`

while [ $int -le $lineno ]
do
eval y='$'$int
echo "$int ) $y" >> usernameoutput
int=`expr $int + 1`
done
echo "finished"