davidktw
Arch-Supremacy Member
- Joined
- Apr 15, 2010
- Messages
- 13,547
- Reaction score
- 1,300
It's often I read in this forum where posters are bashing this and that.
Hence lets have a BASH related challenge ?
Someone in another thread inspired this loop without using loop construct.
We have a challenge that was using Javascript, perhaps our lovely shell script (in specific BASH) is worthy of such a challenge too ?
I know we have quite a few unices savvy software engineers around, perhaps it would be a walk in the park for them ?
QUESTION
Please provide a BASH script having the following constraints.
1) Without resorting to any looping constructs and recursion in BASH or any other programs/applications/utilities other than BASH, print out a counting from 1 to
INPUT
OUTPUT
Each separate line will show a count from
Below are samples of the expected output
NOTE
Any other utilities are like
Happy bashing!

Hence lets have a BASH related challenge ?
Someone in another thread inspired this loop without using loop construct.
We have a challenge that was using Javascript, perhaps our lovely shell script (in specific BASH) is worthy of such a challenge too ?
I know we have quite a few unices savvy software engineers around, perhaps it would be a walk in the park for them ?
QUESTION
Please provide a BASH script having the following constraints.
1) Without resorting to any looping constructs and recursion in BASH or any other programs/applications/utilities other than BASH, print out a counting from 1 to
N via the standard out (terminal display) when the script is invoked as such
Bash:
$ ./count.sh N
INPUT
0 <= N <= 100000OUTPUT
Each separate line will show a count from
1 to N should N > 0 and nothing will be printed should N == 0.Below are samples of the expected output
Bash:
$ ./count.sh 0
$ ./count.sh 1
1
$ ./count.sh 5
1
2
3
4
5
$ ./count.sh 10
1
2
3
4
5
6
7
8
9
10
$ ./count.sh 1000
1
2
3
4
5
6
7
8
9
10
11
...
993
994
995
996
997
998
999
1000
$
NOTE
Any other utilities are like
ls, find, awk, etc. If it is not a builtin command in BASH, then it is considered a separate application/program/utilities from the shell script. There are cases where there are built-in commands in BASH that is also found as a separate utility in the unix system, such as echo, kill. In this case, you are free to use these built-in constructs found in BASH. We will stick with BASH version 4.3 and later, using the Linux environment for this challenge. I have also rule out recursion for this challenge because BASH allows for changing of the call stack to be virtually unlimited (obviously is limited by memory). There is something else in unix that will help to solve this problem. The solution can potentially loop forever as long as the system is running, meaning if time is given, your solution should keep running non-stop. However in the case of this question, we have set a max of N.Happy bashing!
Last edited: