I want to create a for loop that runs from 1 to a number stored in a variable. But it produces this error:
Syntax error: Bad for loop variable
This is my script:
#!/bin/bash
count_lines ()
{
local f=$1
l=`wc -l $f | sed 's/^\([0-9]*\).*$/\1/'`
}
echo "$0 counts the lines of code"
l=0
while [ "$*" != "" ]
do
count_lines $1
echo "$1: $l"
shift
done
for(( i= 0 ; i <= ${l} ; i++))
do
title=$(grep -oPm1 "(?<=<title>)[^<]+" <<< "$0")
echo "$title"
done