Moin,
Ich möchte an einer Stelle meines Scripts .svg Dateien mit dem Befehl
1 | find -name "*.svg" -exec sh -c 'inkscape $1 --export-dpi=300 --export-type="png"' _ {} \ |
in .png Dateien exportieren. Da es sich um eine Stapelverarbeitung geht möchte ich dort eine Progressbar hinzufügen. Hab dazu diese hier gefunden: https://stackoverflow.com/questions/238073/how-to-add-a-progress-bar-to-a-shell-script?page=1&tab=votes#tab-top
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # 1. Create ProgressBar function # 1.1 Input is currentState($1) and totalState($2) function ProgressBar { # Process data let _progress=(${1}*100/${2}*100)/100 let _done=(${_progress}*4)/10 let _left=40-$_done # Build progressbar string lengths _fill=$(printf "%${_done}s") _empty=$(printf "%${_left}s") # 1.2 Build progressbar strings and print the ProgressBar line # 1.2.1 Output example: # 1.2.1.1 Progress : [########################################] 100% printf "\rProgress : [${_fill// /#}${_empty// /-}] ${_progress}%%" } # Variables _start=1 # This accounts as the "totalState" variable for the ProgressBar function _end=100 # Proof of concept for number in $(seq ${_start} ${_end}) do sleep 0.1 ProgressBar ${number} ${_end} done printf '\nFinished!\n' |
Mein erstes Problem ist erstmal wenn ich die Ausgabe mit > /dev/null unterdrücken möchte funktioniert dies nicht. Trotz Umleitung wird der entsprechende export in der Shell dennoch ausgegeben. Wie genau kann ich in dem Fall die Shellausgabe unterdrücken.
Falls jemand zum anschließenden Progressbar hinzufügen einen Tipp geben kann, wie ich die obige Funktion einfügen kann wäre es auch super. Aber zu allererst wäre das unterdrücken der Ausgabe erstmal am wichtigsten.
Danke schonmal im vorraus.
Greetz