At first, I am pretty new into bash scripting.
So I have 2 files, lets call them A and B.
In A are URLs and in B are several logs. What I want is, insert a $actual_count after every occurrence of $element
There is only 1 $actual_count for 1 $element
IFS=',' read -r -a array < $1
for element in "${array[@]}"
do
actual_count=`cat $2 | grep $element |grep css | wc -l`
sed -i ':'"$element"': a '"$actual_count"'' daily_output
done
this code returns me after a found $element
all $actual_count of this loop squared and multiplied with all elements of the array.
Like (all $actual_count generated in this loop)²*sizeof array. (Thats a lot).
I don't know where I messed up that bad.
I hope you can help me.
Sorry for my bad english xD
Kind regards fune
Edit: if I use a fixed search pattern, then it works fine.
Edit 2: thx for your answer!
Soo this the file for the array:
this/is/the/first.html,this/is/the/sec.html,this/is/the/third.html,this/is/the/forth.html,this/is/the/fifth.html,an/so/on.html
the file for actual_count is a apache-access logfile.
I want my result like this:
this/is/the/first.html
2
this/is/the/sec.html
3
this/is/the/third.html
0
this/is/the/forth.html
1
...
$1
file, it has exactly 1 line with comma-separated elements? You'll want to show us what's in A and B, and show us what the desired output should look like.