Discussion:
for loops with /bin/sh on command line.
Vincent Hoffman
2012-07-08 16:47:25 UTC
Permalink
I'm sure I'm being dim, but why cant I do a for loop on the command line
using /bin/sh ?
am I suffering from too much use of bash and as such shouldnt expect it
to work?


banshee# for foo in 1 2 3 ; do echo $foo ; done
for: Command not found.
foo: Undefined variable.
banshee# echo 'for foo in 1 2 3; do echo $foo ; done' > bahh.sh
banshee# sh bahh.sh
1
2
3
banshee#



Vince
Wojciech Puchar
2012-07-08 16:50:54 UTC
Permalink
Post by Vincent Hoffman
am I suffering from too much use of bash and as such shouldnt expect it
to work?
maybe. i actually use bash for script.
Post by Vincent Hoffman
banshee# for foo in 1 2 3 ; do echo $foo ; done
for: Command not found.
foo: Undefined variable.
banshee# echo 'for foo in 1 2 3; do echo $foo ; done' > bahh.sh
banshee# sh bahh.sh
1
2
3
banshee#
Vince
_______________________________________________
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
Wojciech Puchar
2012-07-08 16:51:23 UTC
Permalink
Post by Vincent Hoffman
banshee# for foo in 1 2 3 ; do echo $foo ; done
for: Command not found.
foo: Undefined variable.
banshee# echo 'for foo in 1 2 3; do echo $foo ; done' > bahh.sh
banshee# sh bahh.sh
1
2
3
banshee#
echo $SHELL
is it /bin/sh really?
Vincent Hoffman
2012-07-08 16:59:07 UTC
Permalink
Post by Wojciech Puchar
Post by Vincent Hoffman
banshee# for foo in 1 2 3 ; do echo $foo ; done
for: Command not found.
foo: Undefined variable.
banshee# echo 'for foo in 1 2 3; do echo $foo ; done' > bahh.sh
banshee# sh bahh.sh
1
2
3
banshee#
echo $SHELL
is it /bin/sh really?
Doh, yes that was it. Cant believe I forgot to check. I was running csh
for no good reason.

Thanks,
Vince
Wojciech Puchar
2012-07-08 18:03:10 UTC
Permalink
Post by Vincent Hoffman
Post by Wojciech Puchar
Post by Vincent Hoffman
3
banshee#
echo $SHELL
is it /bin/sh really?
Doh, yes that was it. Cant believe I forgot to check. I was running csh
for no good reason.
the reason is that it is default.

Continue reading on narkive:
Loading...