How can I adapt this bash progress bar function for AIX ksh88? [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash 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 substitution
pt=$(printf "%*s" "$(( 80*20/100 ))" "") I get : printf: bad conversion










share|improve this question









New contributor




user322130 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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 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










  • I would be easier to rewrite from scratch.
    – Ipor Sircer
    Nov 21 at 17:33














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 substitution
pt=$(printf "%*s" "$(( 80*20/100 ))" "") I get : printf: bad conversion










share|improve this question









New contributor




user322130 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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 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










  • I would be easier to rewrite from scratch.
    – Ipor Sircer
    Nov 21 at 17:33












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 substitution
pt=$(printf "%*s" "$(( 80*20/100 ))" "") I get : printf: bad conversion










share|improve this question









New contributor




user322130 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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 substitution
pt=$(printf "%*s" "$(( 80*20/100 ))" "") I get : printf: bad conversion







ksh aix






share|improve this question









New contributor




user322130 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




user322130 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Nov 21 at 17:41









SGUser

31




31






New contributor




user322130 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 21 at 15:28









user322130

1




1




New contributor




user322130 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





user322130 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






user322130 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




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 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










  • 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











  • 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










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





share|improve this answer






















  • 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

















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





share|improve this answer






















  • 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














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





share|improve this answer






















  • 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












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





share|improve this answer














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






share|improve this answer














share|improve this answer



share|improve this answer








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
















  • 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


Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?