script arg or parameters limitation

Hi,

I would like to ask some info on the script arguments/parameters. Does script arguments had limitation like inside or deep inside the loop in which it will not function as it use to be.

as an example:
$2 not working

command2 () {
for log in $LOG{1,2,3}
	do
	if [ -e $log ] && [ -s $log ]; then
	echo
	echo BEGIN $log
	grep -E "$DATE" $log | grep -E "$2"  2> $SCRIPT
	echo
	echo END $log
	echo
	fi
	done
}

$2 need to declare as another variable to work

par2=echo $2
command2 () {
for log in $LOG{1,2,3}
	do
	if [ -e $log ] && [ -s $log ]; then
	echo
	echo BEGIN $log
	grep -E "$DATE" $log | grep -E "$par2"  2> $SCRIPT
	echo
	echo END $log
	echo
	fi
	done
}

Call the function with the parameters of the script to use them as $1, $2....in your function.

command2 "$1" "$2"
1 Like

@Franklin52: thanks thats all i need..