<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://wiki.bralug.de/wiki-common/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
		<id>https://wiki.bralug.de/index.php?action=history&amp;feed=atom&amp;title=Runden_und_Formatieren_von_Zahlen_in_der_bash</id>
		<title>Runden und Formatieren von Zahlen in der bash - Versionsgeschichte</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.bralug.de/index.php?action=history&amp;feed=atom&amp;title=Runden_und_Formatieren_von_Zahlen_in_der_bash"/>
		<link rel="alternate" type="text/html" href="https://wiki.bralug.de/index.php?title=Runden_und_Formatieren_von_Zahlen_in_der_bash&amp;action=history"/>
		<updated>2026-05-16T04:00:01Z</updated>
		<subtitle>Versionsgeschichte dieser Seite in BraLUG-Wiki</subtitle>
		<generator>MediaWiki 1.19.1</generator>

	<entry>
		<id>https://wiki.bralug.de/index.php?title=Runden_und_Formatieren_von_Zahlen_in_der_bash&amp;diff=4691&amp;oldid=prev</id>
		<title>MaD: kategorisiert</title>
		<link rel="alternate" type="text/html" href="https://wiki.bralug.de/index.php?title=Runden_und_Formatieren_von_Zahlen_in_der_bash&amp;diff=4691&amp;oldid=prev"/>
				<updated>2006-08-26T15:27:37Z</updated>
		
		<summary type="html">&lt;p&gt;kategorisiert&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr valign='top'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Nächstältere Version-&gt;&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Version vom 26. August 2006, 15:27 Uhr&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;[[Kategorie:Tipps und Tricks]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Es bestand in einem Script der Wunsch Zahlen in ein lesbares Format umzuwandeln und auszugeben. Speziell handelte es sich um die Anzahl von Bytes, die über die Netzwerkschnittstelle gehen. Ab einer Zahl &amp;gt; 1000000 kann das dann schon mal leicht unübersichtlich werden.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Es bestand in einem Script der Wunsch Zahlen in ein lesbares Format umzuwandeln und auszugeben. Speziell handelte es sich um die Anzahl von Bytes, die über die Netzwerkschnittstelle gehen. Ab einer Zahl &amp;gt; 1000000 kann das dann schon mal leicht unübersichtlich werden.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>MaD</name></author>	</entry>

	<entry>
		<id>https://wiki.bralug.de/index.php?title=Runden_und_Formatieren_von_Zahlen_in_der_bash&amp;diff=4416&amp;oldid=prev</id>
		<title>Bergeruw: printf...</title>
		<link rel="alternate" type="text/html" href="https://wiki.bralug.de/index.php?title=Runden_und_Formatieren_von_Zahlen_in_der_bash&amp;diff=4416&amp;oldid=prev"/>
				<updated>2006-05-30T06:51:47Z</updated>
		
		<summary type="html">&lt;p&gt;printf...&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr valign='top'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Nächstältere Version-&gt;&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Version vom 30. Mai 2006, 06:51 Uhr&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 129:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 129:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Die Mathematiker können sich ja mal die Berechnung von &amp;lt;code&amp;gt;z1&amp;lt;/code&amp;gt; und &amp;lt;code&amp;gt;z2&amp;lt;/code&amp;gt; genauer ansehen, ob da etwas zu vereinfachen wäre. Aber Vorsicht, es kann nur mit ganzen Zahlen gerechnet werden (z.B. 1/20 würde 0 ergeben...).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Die Mathematiker können sich ja mal die Berechnung von &amp;lt;code&amp;gt;z1&amp;lt;/code&amp;gt; und &amp;lt;code&amp;gt;z2&amp;lt;/code&amp;gt; genauer ansehen, ob da etwas zu vereinfachen wäre. Aber Vorsicht, es kann nur mit ganzen Zahlen gerechnet werden (z.B. 1/20 würde 0 ergeben...).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Als letztes &amp;quot;externe&amp;quot; Kommando wäre noch &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt; zu ersetzen, wobei mir aber wichtig ist, dass die Ausgabe immer gleich formatiert ist (3 Stellen vor dem Punkt; 1 Stelle nach dem Punkt; eine Stelle für das Vorsatzzeichen).&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Bergeruw</name></author>	</entry>

	<entry>
		<id>https://wiki.bralug.de/index.php?title=Runden_und_Formatieren_von_Zahlen_in_der_bash&amp;diff=4415&amp;oldid=prev</id>
		<title>Bergeruw: noch ein Hinweis...</title>
		<link rel="alternate" type="text/html" href="https://wiki.bralug.de/index.php?title=Runden_und_Formatieren_von_Zahlen_in_der_bash&amp;diff=4415&amp;oldid=prev"/>
				<updated>2006-05-30T06:45:53Z</updated>
		
		<summary type="html">&lt;p&gt;noch ein Hinweis...&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr valign='top'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Nächstältere Version-&gt;&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Version vom 30. Mai 2006, 06:45 Uhr&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 128:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 128:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160; }&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160; }&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Die Mathematiker können sich ja mal die Berechnung von &amp;lt;code&amp;gt;z1&amp;lt;/code&amp;gt; und &amp;lt;code&amp;gt;z2&amp;lt;/code&amp;gt; genauer ansehen, ob da etwas zu vereinfachen wäre.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Die Mathematiker können sich ja mal die Berechnung von &amp;lt;code&amp;gt;z1&amp;lt;/code&amp;gt; und &amp;lt;code&amp;gt;z2&amp;lt;/code&amp;gt; genauer ansehen, ob da etwas zu vereinfachen wäre&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;. Aber Vorsicht, es kann nur mit ganzen Zahlen gerechnet werden (z.B. 1/20 würde 0 ergeben...)&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Bergeruw</name></author>	</entry>

	<entry>
		<id>https://wiki.bralug.de/index.php?title=Runden_und_Formatieren_von_Zahlen_in_der_bash&amp;diff=4414&amp;oldid=prev</id>
		<title>Bergeruw: Variante ohne expr...</title>
		<link rel="alternate" type="text/html" href="https://wiki.bralug.de/index.php?title=Runden_und_Formatieren_von_Zahlen_in_der_bash&amp;diff=4414&amp;oldid=prev"/>
				<updated>2006-05-30T06:40:41Z</updated>
		
		<summary type="html">&lt;p&gt;Variante ohne expr...&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr valign='top'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Nächstältere Version-&gt;&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Version vom 30. Mai 2006, 06:40 Uhr&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 91:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 91:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160; 298.0G&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160; 298.0G&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160;  1.0K&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160;  1.0K&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Hier eine Version, die ohne &amp;lt;code&amp;gt;expr&amp;lt;/code&amp;gt; auskommt (Vorschlag von [[Benutzer:MaD|MaD]]) und damit auch schneller arbeitet (Ergebnisausgabe der Testbeispiele ist wie oben):&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt; function my_format () &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt; {&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; &amp;#160;  # 1.Uebergabeparameter ist die Zahl&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; &amp;#160;  zahl=$1&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; &amp;#160;  # Vorsatzzeichen und Teiler bestimmen&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; &amp;#160;  if [ $zahl -gt 999999999 ] ; then &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt; 	t=1000000000&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt; 	e=G&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; &amp;#160;  else&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt; 	if [ $zahl -gt 999999 ] ; then&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt; 	&amp;#160; &amp;#160; t=1000000&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt; 	&amp;#160; &amp;#160; e=M&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt; 	else&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt; 	&amp;#160; &amp;#160; if [ $zahl -gt 999 ] ; then&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt; 		t=1000&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt; 		e=K&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt; 	&amp;#160; &amp;#160; else&amp;#160; &amp;#160; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt; 		# gleich ausgeben, es muss nichts formatiert werden&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt; 		printf &amp;quot;%5d &amp;quot; $zahl&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt; 		return&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt; 	&amp;#160; &amp;#160; fi&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt; 	fi&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; &amp;#160;  fi&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; &amp;#160;  # Runden und ganzzahligen Teil berechnen&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; &amp;#160;  z1=$((($zahl+($t/20))/$t))&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; &amp;#160;  # Rest auf eine Stelle berechnen&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; &amp;#160;  z2=$(((($zahl+($t/20))%$t)/($t/10)))&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; &amp;#160;  # und ausgeben&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; &amp;#160;  printf &amp;quot;%3d.%1d%s&amp;quot; $z1 $z2 $e&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; &amp;#160;  return&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt; }&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Die Mathematiker können sich ja mal die Berechnung von &amp;lt;code&amp;gt;z1&amp;lt;/code&amp;gt; und &amp;lt;code&amp;gt;z2&amp;lt;/code&amp;gt; genauer ansehen, ob da etwas zu vereinfachen wäre.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Bergeruw</name></author>	</entry>

	<entry>
		<id>https://wiki.bralug.de/index.php?title=Runden_und_Formatieren_von_Zahlen_in_der_bash&amp;diff=4409&amp;oldid=prev</id>
		<title>Bergeruw: neu...</title>
		<link rel="alternate" type="text/html" href="https://wiki.bralug.de/index.php?title=Runden_und_Formatieren_von_Zahlen_in_der_bash&amp;diff=4409&amp;oldid=prev"/>
				<updated>2006-05-29T12:03:32Z</updated>
		
		<summary type="html">&lt;p&gt;neu...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Es bestand in einem Script der Wunsch Zahlen in ein lesbares Format umzuwandeln und auszugeben. Speziell handelte es sich um die Anzahl von Bytes, die über die Netzwerkschnittstelle gehen. Ab einer Zahl &amp;gt; 1000000 kann das dann schon mal leicht unübersichtlich werden.&lt;br /&gt;
&lt;br /&gt;
Aus diesem Grund hier mal ein kleines Shell-Script, innerhalb dessen die Funktion ''my_format'' eine Umformatierung (und die damit eventuell notwendige Rundung) des Wertes vornimmt. Als Ausgabeformat soll ungefähr soetwas rauskommen:&lt;br /&gt;
&lt;br /&gt;
* Wert &amp;lt; 1000: xxx&lt;br /&gt;
* Wert &amp;gt;= 10000: xxx.xK&lt;br /&gt;
* Wert &amp;gt;= 1000000: xxx.xM&lt;br /&gt;
* Wert &amp;gt;= 1000000000: xxx.xG&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 &lt;br /&gt;
 #*******************************************************************&lt;br /&gt;
 #                   my_format&lt;br /&gt;
 #                Uwe Berger; 2006&lt;br /&gt;
 #&lt;br /&gt;
 # Rundet und formatiert eine uebergebene Zahl in ein besser lesbares&lt;br /&gt;
 # Format um -&amp;gt; Format: xxx.x&amp;lt;G|M|K| &amp;gt;&lt;br /&gt;
 # (G=Giga, M=Mega, K=Kilo)&lt;br /&gt;
 #*******************************************************************&lt;br /&gt;
 function my_format () &lt;br /&gt;
 {&lt;br /&gt;
    # 1.Uebergabeparameter ist die Zahl&lt;br /&gt;
    zahl=$1 &lt;br /&gt;
    # Vorsatzzeichen und Teiler bestimmen&lt;br /&gt;
    if [ $zahl -gt 999999999 ] ; then&lt;br /&gt;
 	t=1000000000&lt;br /&gt;
 	e=G&lt;br /&gt;
    else&lt;br /&gt;
 	if [ $zahl -gt 999999 ] ; then&lt;br /&gt;
 	    t=1000000&lt;br /&gt;
 	    e=M&lt;br /&gt;
 	else&lt;br /&gt;
 	    if [ $zahl -gt 999 ] ; then&lt;br /&gt;
 		t=1000&lt;br /&gt;
 		e=K&lt;br /&gt;
 	    else    &lt;br /&gt;
 		# gleich ausgeben, es muss nichts formatiert werden&lt;br /&gt;
 		printf &amp;quot;%5d &amp;quot; $zahl&lt;br /&gt;
 		return&lt;br /&gt;
 	    fi&lt;br /&gt;
 	fi&lt;br /&gt;
    fi&lt;br /&gt;
    # Zwischenvars. zum Runden berechnen&lt;br /&gt;
    tr=`expr $t / 20`;&lt;br /&gt;
    tt=`expr $t / 10`;&lt;br /&gt;
    # Runden und ganzzahligen Teil berechnen&lt;br /&gt;
    zr=`expr $zahl + $tr`&lt;br /&gt;
    z1=`expr $zr / $t`&lt;br /&gt;
    # Rest auf eine Stelle berechnen&lt;br /&gt;
    z2=`expr $zr % $t`&lt;br /&gt;
    z2=`expr $z2 / $tt`&lt;br /&gt;
    # und ausgeben&lt;br /&gt;
    printf &amp;quot;%3d.%1d%s&amp;quot; $z1 $z2 $e&lt;br /&gt;
    return&lt;br /&gt;
 }&lt;br /&gt;
 # ... und Funktion mal testen...&lt;br /&gt;
 my_format 298&lt;br /&gt;
 echo &lt;br /&gt;
 my_format 2980&lt;br /&gt;
 echo &lt;br /&gt;
 my_format 29800&lt;br /&gt;
 echo &lt;br /&gt;
 my_format 298000&lt;br /&gt;
 echo &lt;br /&gt;
 my_format 2980000&lt;br /&gt;
 echo &lt;br /&gt;
 my_format 29800000&lt;br /&gt;
 echo &lt;br /&gt;
 my_format 298000000&lt;br /&gt;
 echo &lt;br /&gt;
 my_format 2980000000&lt;br /&gt;
 echo &lt;br /&gt;
 my_format 29800000000&lt;br /&gt;
 echo &lt;br /&gt;
 my_format 298000000000&lt;br /&gt;
 echo &lt;br /&gt;
 my_format 1000&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Als Ergebnis erhält man:&lt;br /&gt;
   298&lt;br /&gt;
   3.0K&lt;br /&gt;
  29.8K&lt;br /&gt;
 298.0K&lt;br /&gt;
   3.0M&lt;br /&gt;
  29.8M&lt;br /&gt;
 298.0M&lt;br /&gt;
   3.0G&lt;br /&gt;
  29.8G&lt;br /&gt;
 298.0G&lt;br /&gt;
   1.0K&lt;/div&gt;</summary>
		<author><name>Bergeruw</name></author>	</entry>

	</feed>