My command looks like this:
P8.1 ~basicsys/win15/ex8/d1 cd 3 D A X F1 B
So I have three parameters: dir (holds the directory) str (a string im looking for) num (line number)
What I need to do is to go over the files and check if the str is appearing in line num.
And I need to print something like :
[File] [number of times str appeared in line number num somewhere in the tree of the directory].
output:
A 1
B 3
D 2
F1 1
X 0
From my debugging i found that I have problem with the line that im preforming the find
command (in the while).
This is my code:
dir=$1
shift
str=$1
shift
num=$1
shift
echo 'head -$num | tail -1' >| getLine
echo -n "" >| out
chmod +x getLine
while [ $# -gt 0 ]
do
echo -n $1 " " >> out
find $dir -type f -name $1 -exec getLine {} \; >| tmp
egrep -c $str tmp >> out
shift
done
sort out
maybe the problem is also at echo 'head -$num | tail -1'
pleaseeeee help :/ thanks!!!