Embedded Linux Shell Script Review

WECM100/base02.sh

Description: Basic shell script demonstrating a while loop using WSL on Windows 11.

Environment Details

Attribute Value
Machine ASUS VIVO BOOK, Mouse Windows 11
Linux (WSL) Ubuntu 24.04.1 LTS
IDE VS Code
uname -a Linux asus-oda 5.15.167.4-microsoft-standard-WSL2 1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
pwd /home/miura
whoami miura
which bash /usr/bin/bash
Current Directory /home/miura/WECM100

Script: base02.sh

        
#!/usr/bin/bash
i=0
while [ $i -ne 10 ]
do
    ((i++))
    printf "{\"count\":%d}\n" $i
done
        
    

Review Points

Potential Improvements (For Beginners)

Execution and Result

Commands:

        
$ chmod +x base02.sh
$ ./base02.sh
        
    

Result:

        
{"count":1}
{"count":2}
{"count":3}
{"count":4}
{"count":5}
{"count":6}
{"count":7}
{"count":8}
{"count":9}
{"count":10}