You are viewing a single comment's thread. Return to all comments →
This to me seems like the most concise, elegant way of implementing the for loop, but it seems like it's only a BASH4.0v+ feature.
As per our environment the version of bash we support is 4.3.11
but what if we are programming unix shell script ?
unix shell is bash
It's not true. For example on OpenBSD shell is ksh, not bash.
Get used to always have SheBang #!/bin/bash as the first line of the script.
Bash ususally is installed. If not try ksh, it is very similar.
If you want to write compatible script, use dash from Debian and use SheBang #!/bin/sh. But beware, many external programs are a bit different, for example on OS-X.