0
for((i=1; i<=rows; i++))
do
  for((j=1; j<=rows - i; j++))
  do
    echo -n "  "
  done
  for((j=1; j<=2*i - 1; j++))
  do
    echo -n "* "
  done
  echo
done

In for((j=1; j<=2*i - 1; j++)) this line, i got error of operand expected (error token is "<=")

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    Which shell, specifically? This is syntax that only works in extended shells; it won't work in `sh`. (It's also bad form to not put spaces between words; in this case, between `for` and `((`; but that won't necessarily cause problems). – Charles Duffy Aug 28 '22 at 16:20
  • See your code working fine when run with bash at https://ideone.com/ErUIwP – Charles Duffy Aug 28 '22 at 16:23
  • BTW, if you want broad compatibility, it's also best to replace `echo -n foo` with `printf %s foo`. See the APPLICATION USAGE and RATIONALE sections of https://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html – Charles Duffy Aug 28 '22 at 16:28

0 Answers0