Well, O'Reilly's "Classic Shell Scripting", Addison-Wesley's "Shell Programming in Unix, Linux and OS X", and several online tutorials I found.
I know ((...)) means it's an arithmetic expression, which i++ or i+1 in my eyes is, ain't it?
It would have helped I you at least quoted one source (preferably reputable) that states this.
Sorry. You're right. I just thought more about "Dude, that's so obsolete..." so I thought it wasn't necessary.
(I just combined all I tried in this source to post only one)
sh:
#!/bin/sh
fileliste=$(ls *sh)
i=0
#n=0
for datei in $fileliste
do
$((n++))
j=$((n++))
i=$((i + 1))
# echo $datei
done
echo
echo $n
echo $i
echo $j
exit 0
#!/bin/sh =>
./temp.sh: arithmetic expression: expecting EOF: "n++"
#!/bin/bash =>
./temp.sh: Command not found.
But if do a
bash ./temp.sh
the bash moans about line 8
$((n++))
, only.
Commenting that line in bash it works.
Doing the same in sh doesn't.
I thought it might be caused by default I'm in tcsh (I know the shebang redirects to the according shell, but there are "few exotic minor" issues between running a sh script from tcsh or sh. But even when I'm doing this in sh or bash, the same.
So I thought:"Ask the guys!"
So,
eternal_noob was right.
It's a bash thing.
However, I don't know why this is in books primarily about sh, not mentioning it's bash
Since I don't see much saving in writing this way, I can live with "good old"
i=$((i + 1))
, but I wanted to understand why it's not working.
Thanks.
Edit:
Doing
bash ./temp.sh
with line 8 as
((n++))
with #!/bin/bash, works.

Seems to me I either stumbled over some (minor) error in my books, or about this somethings was changed,...but 2017 does not seem that old to me...
However, I stay with the common way.
Thanks guys!