开发者

Linux Bash novice, I need a script to use the tab escape character and bel to format output from 10-1 [closed]

开发者 https://www.devze.com 2022-12-07 20:21 出处:网络
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.

This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.

开发者_运维技巧

Closed 5 hours ago.

Improve this question

How do I get bash script to output the following?

Output using \t
=================
Counter = 10
Counter = 9
Counter = 8
Counter = 7
Counter = 6
Counter = 5
Counter = 4
Counter = 3
Counter = 2
Counter = 1
Bell indicating end of script

I know how to do this script for increment like below:

#!/bin/bash
# simple escape character

clear
# output using tab
echo
echo Output using \\t
echo =================
counter=1
while [ $counter -le 10 ]
do
    echo -e "\tCounter \t= \t$counter
    ((counter++))
done
echo
echo -e "\aBell indicating end of script"
echo

I cannot find any text in books or online to show how to decrement. With this script it prints out values from 1-10 incrementing. I thought it was just using -- where the ++ is? Can anyone please explain this to me? I appreciate your help for a complete novice!


I just used this script below

#!/bin/bash
# simple escape character

clear
# output using tab
echo
echo Output using \\t
echo =================
counter=10
while [ $counter -ge 1 ]
do
    echo -e "Counter \t= \t$counter"
    ((counter++))
done
echo
echo -e "\aBell indicating end of script"
echo

to get the following output,

Output using \t
=================
Counter     =   10
Counter     =   9
Counter     =   8
Counter     =   7
Counter     =   6
Counter     =   5
Counter     =   4
Counter     =   3
Counter     =   2
Counter     =   1

Bell indicating end of script

0

精彩评论

暂无评论...
验证码 换一张
取 消