How can I adapt this bash progress bar function for AIX ksh88? [closed]
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have a bash script for progress bar and I use it when I work in bash:
#!/bin/bash
prog() %3d %% %s" "$w" "$pt" "$p" "$*";
# test loop
for x in 1..100 ; do
prog "$x" traitement en cours...
#sleep .1 # do some work here
#traitement
done ; echo
But now I'm using AIX KSH88 and I'm tried to convert this script but I meet several mistakes.
Like :pt=$pt// /.
Bad substitutionpt=$(printf "%*s" "$(( 80*20/100 ))" "")
I get : printf: bad conversion
ksh aix
New contributor
closed as unclear what you're asking by Rui F Ribeiro, X Tian, schily, RalfFriedl, Thomas Nov 22 at 20:03
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
up vote
0
down vote
favorite
I have a bash script for progress bar and I use it when I work in bash:
#!/bin/bash
prog() %3d %% %s" "$w" "$pt" "$p" "$*";
# test loop
for x in 1..100 ; do
prog "$x" traitement en cours...
#sleep .1 # do some work here
#traitement
done ; echo
But now I'm using AIX KSH88 and I'm tried to convert this script but I meet several mistakes.
Like :pt=$pt// /.
Bad substitutionpt=$(printf "%*s" "$(( 80*20/100 ))" "")
I get : printf: bad conversion
ksh aix
New contributor
closed as unclear what you're asking by Rui F Ribeiro, X Tian, schily, RalfFriedl, Thomas Nov 22 at 20:03
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
Mistakes such as? First adjustment will have to be theprintf -v
, turning intov=$(printf ...)
. What else? The brace expansion...
– Jeff Schaller
Nov 21 at 15:44
You appear to be logging in with a second account; register and user your first account to comment on and edit your question.
– Jeff Schaller
Nov 21 at 17:01
I would be easier to rewrite from scratch.
– Ipor Sircer
Nov 21 at 17:33
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a bash script for progress bar and I use it when I work in bash:
#!/bin/bash
prog() %3d %% %s" "$w" "$pt" "$p" "$*";
# test loop
for x in 1..100 ; do
prog "$x" traitement en cours...
#sleep .1 # do some work here
#traitement
done ; echo
But now I'm using AIX KSH88 and I'm tried to convert this script but I meet several mistakes.
Like :pt=$pt// /.
Bad substitutionpt=$(printf "%*s" "$(( 80*20/100 ))" "")
I get : printf: bad conversion
ksh aix
New contributor
I have a bash script for progress bar and I use it when I work in bash:
#!/bin/bash
prog() %3d %% %s" "$w" "$pt" "$p" "$*";
# test loop
for x in 1..100 ; do
prog "$x" traitement en cours...
#sleep .1 # do some work here
#traitement
done ; echo
But now I'm using AIX KSH88 and I'm tried to convert this script but I meet several mistakes.
Like :pt=$pt// /.
Bad substitutionpt=$(printf "%*s" "$(( 80*20/100 ))" "")
I get : printf: bad conversion
ksh aix
ksh aix
New contributor
New contributor
edited Nov 21 at 17:41
SGUser
31
31
New contributor
asked Nov 21 at 15:28
user322130
1
1
New contributor
New contributor
closed as unclear what you're asking by Rui F Ribeiro, X Tian, schily, RalfFriedl, Thomas Nov 22 at 20:03
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as unclear what you're asking by Rui F Ribeiro, X Tian, schily, RalfFriedl, Thomas Nov 22 at 20:03
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
Mistakes such as? First adjustment will have to be theprintf -v
, turning intov=$(printf ...)
. What else? The brace expansion...
– Jeff Schaller
Nov 21 at 15:44
You appear to be logging in with a second account; register and user your first account to comment on and edit your question.
– Jeff Schaller
Nov 21 at 17:01
I would be easier to rewrite from scratch.
– Ipor Sircer
Nov 21 at 17:33
add a comment |
Mistakes such as? First adjustment will have to be theprintf -v
, turning intov=$(printf ...)
. What else? The brace expansion...
– Jeff Schaller
Nov 21 at 15:44
You appear to be logging in with a second account; register and user your first account to comment on and edit your question.
– Jeff Schaller
Nov 21 at 17:01
I would be easier to rewrite from scratch.
– Ipor Sircer
Nov 21 at 17:33
Mistakes such as? First adjustment will have to be the
printf -v
, turning into v=$(printf ...)
. What else? The brace expansion...– Jeff Schaller
Nov 21 at 15:44
Mistakes such as? First adjustment will have to be the
printf -v
, turning into v=$(printf ...)
. What else? The brace expansion...– Jeff Schaller
Nov 21 at 15:44
You appear to be logging in with a second account; register and user your first account to comment on and edit your question.
– Jeff Schaller
Nov 21 at 17:01
You appear to be logging in with a second account; register and user your first account to comment on and edit your question.
– Jeff Schaller
Nov 21 at 17:01
I would be easier to rewrite from scratch.
– Ipor Sircer
Nov 21 at 17:33
I would be easier to rewrite from scratch.
– Ipor Sircer
Nov 21 at 17:33
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
Try:
function prog %-$ws
# test loop
x=1; while ((x <= 100)); do
prog "$x" traitement en cours...
sleep 1 # do some work here
((x+=1))
done
echo
I admit to not keeping up with this solution, but if the intention is for the$p
message ("traitement en cours...") to be on the same line of an 80-column-wide terminal, then I think the length of p needs to be subtracted somewhere.
– Jeff Schaller
Nov 21 at 19:25
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Try:
function prog %-$ws
# test loop
x=1; while ((x <= 100)); do
prog "$x" traitement en cours...
sleep 1 # do some work here
((x+=1))
done
echo
I admit to not keeping up with this solution, but if the intention is for the$p
message ("traitement en cours...") to be on the same line of an 80-column-wide terminal, then I think the length of p needs to be subtracted somewhere.
– Jeff Schaller
Nov 21 at 19:25
add a comment |
up vote
1
down vote
Try:
function prog %-$ws
# test loop
x=1; while ((x <= 100)); do
prog "$x" traitement en cours...
sleep 1 # do some work here
((x+=1))
done
echo
I admit to not keeping up with this solution, but if the intention is for the$p
message ("traitement en cours...") to be on the same line of an 80-column-wide terminal, then I think the length of p needs to be subtracted somewhere.
– Jeff Schaller
Nov 21 at 19:25
add a comment |
up vote
1
down vote
up vote
1
down vote
Try:
function prog %-$ws
# test loop
x=1; while ((x <= 100)); do
prog "$x" traitement en cours...
sleep 1 # do some work here
((x+=1))
done
echo
Try:
function prog %-$ws
# test loop
x=1; while ((x <= 100)); do
prog "$x" traitement en cours...
sleep 1 # do some work here
((x+=1))
done
echo
edited Nov 21 at 18:14
answered Nov 21 at 18:07
Stéphane Chazelas
295k54555898
295k54555898
I admit to not keeping up with this solution, but if the intention is for the$p
message ("traitement en cours...") to be on the same line of an 80-column-wide terminal, then I think the length of p needs to be subtracted somewhere.
– Jeff Schaller
Nov 21 at 19:25
add a comment |
I admit to not keeping up with this solution, but if the intention is for the$p
message ("traitement en cours...") to be on the same line of an 80-column-wide terminal, then I think the length of p needs to be subtracted somewhere.
– Jeff Schaller
Nov 21 at 19:25
I admit to not keeping up with this solution, but if the intention is for the
$p
message ("traitement en cours...") to be on the same line of an 80-column-wide terminal, then I think the length of p needs to be subtracted somewhere.– Jeff Schaller
Nov 21 at 19:25
I admit to not keeping up with this solution, but if the intention is for the
$p
message ("traitement en cours...") to be on the same line of an 80-column-wide terminal, then I think the length of p needs to be subtracted somewhere.– Jeff Schaller
Nov 21 at 19:25
add a comment |
Mistakes such as? First adjustment will have to be the
printf -v
, turning intov=$(printf ...)
. What else? The brace expansion...– Jeff Schaller
Nov 21 at 15:44
You appear to be logging in with a second account; register and user your first account to comment on and edit your question.
– Jeff Schaller
Nov 21 at 17:01
I would be easier to rewrite from scratch.
– Ipor Sircer
Nov 21 at 17:33