Sponsored Content
Top Forums Shell Programming and Scripting Script mit Laufvariable schlanker gestalten? Post 302385045 by Lock3 on Thursday 7th of January 2010 02:35:35 AM
Old 01-07-2010
Question Script mit Laufvariable schlanker gestalten?

Hiho.

Ich habe mit meinen rudimentären Scriptkenntnissen folgendes nicht sehr elegantes Script geschrieben und würde es gern in einer etwas eleganteren Form haben.

Code:
i=0                                                                                                                                    #herauslesen aller Dateien welche auf .sys enden und füllen eines Arrays
for Par in *.sys ; do
    Par2[$i]="$Par" ;
    i=$((i + 1)) ;
done
 
#Laufvariablen mit den Werten des Arrays füllen 
a=${Par2[0]} ; b=${Par2[1]} ; c=${Par2[2]}; d=${Par2[3]}; e=${Par2[4]}; f=${Par2[5]}; g=${Par2[6]}; h=${Para[7]}; i=${Par2[8]}; 
 
#Dateiendung aus Variablen entfernen 
a=`echo $a | sed 's/\(.*\).sys/\1/'` ; b=`echo $b | sed 's/\(.*\).sys/\1/'` ; c=`echo $c | sed 's/\(.*\).sys/\1/'`;
 
echo "eingebundene Modell"
echo "---------------------------------------"
echo " $a "
echo " $b "
echo " $c "
 
sleep 2
 
        echo " ++---------------------------------+"
        echo " || 01 (TI+MM) --> Alle Berechnen  "  
        echo " || 02 (TI+MM) --> $a Berechnen    "
        echo " || 03 (TI+MM) --> $b Berechnen    "
 
   read ANTW
   case $ANTW in
 
01) Anweisung1
02) Anweisung2
03) Anweisung3
 
esac

Dies ist exemplarisch für die Variablen a bis c . Das Script läuft bis Variable i, doch wenn ich mehr als diese 9 .sys-Dateien finden sollte wirds blöd.
Nun hab ich leider keine Ahnung, wie ich die Sache über die Laufvariable i allgemeingültiger gestalten kann. Smilie

Wäre für jeden Rat dankbar.

Mfg
die Locke
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Xlib: Invalid MIT-MAGIC-COOKIE-1

Anyone: I have a very annoying problem on one of our servers (running Solaris 8). when ever I try to run "xhost +" with the display set at "localhost:0.0" I get the following error: xhost + Xlib: connection to "finappprod:0.0" refused by server Xlib: Invalid... (1 Reply)
Discussion started by: errolg
1 Replies

2. Shell Programming and Scripting

Bash: Zeilen aus Datei mit cat und grep in dynamisches Array schreiben

Hallo, ich habe eine Datei "Kino.ini" die z.B. wie folgt aussieht * KINOFILM A bla bla KINOFILM B blubb blubb KINOFILM C Ich möchte nun die Datei "Kino.ini" per cat und grep auslesen und testen ob der String KINOFILM nur mit einem '*' am Anfang vorkommt. In dieser Beispieldatei... (3 Replies)
Discussion started by: ABE2202
3 Replies

3. Shell Programming and Scripting

shell script vorher batch mit curl

salve! this in windows command script (batch). i need it for mac....unix or linux @echo off Echo Router reconnect: AVM FRITZ!BOX FON WLAN 7170 curl "http://192.168.10.10:49000/upnp/control/WANIPConn1" -H "Content-Type: text/xml; charset="utf-8"" -H... (1 Reply)
Discussion started by: onkeldave
1 Replies

4. Shell Programming and Scripting

Script mit Laufvariable schlanker gestalten?

Hiho. Ich habe mit meinen rudimentären Scriptkenntnissen folgendes nicht sehr elegantes Script geschrieben und würde es gern in einer etwas eleganteren Form haben. i=0 ... (2 Replies)
Discussion started by: Lock3
2 Replies

5. Shell Programming and Scripting

mit Sed Text aus Datei nur nach dem ersten Treffer einfügen

Hello, I'm new in Shell scripting but i should write a script, which inserts the license header out of a txt-File into the files in our Projekt. For the Java classes it runs without Problems but for XML files not. At xml-files i have to put the license Header after the xml-Header (?xml... (2 Replies)
Discussion started by: PhoenixONE
2 Replies

6. Shell Programming and Scripting

Suchen und Ersetzen mit AWK

Hallo, ich habe mir mit meinen dürftigen Programmierkenntnissen ein Script zusammengebastelt über das ich in einem bestimmten Odner mit AWK alle Dateien eines Verzeichnis durchsuche und bestimmte Bezeichungen aller Dateien ändern kann. Es funktioniert auch soweit, nur hätte ich gerne auch die... (1 Reply)
Discussion started by: ruffi
1 Replies

7. Solaris

rdesktop zugriff auf W2K8R2 Farm mit NLB und Session Broke - server sent an unexpectedly long string

Hallo :-) Ich habe da ein Problem beim Zugriff von Solaris mittels rdesktop auf eine TS Farm unter W2K8R2 mit NLB und Session Broker. Ich bekomme folgende Fehlermeldung: user@sunray2xxx /h/user/Desktop 150 > rdesktop terminalserver WARNING: Remote desktop does not support colour... (1 Reply)
Discussion started by: chrischi1978
1 Replies

8. What is on Your Mind?

EdX - Founded by Harvard University and MIT in 2012

Is anyone actively learning, auditing or participating (for credit) at edX? There are some really great science and engineering programs there and they are all free to audit. For example, take a look at these classes related to: C Programming Quantum Physics Computer Science ... (6 Replies)
Discussion started by: Neo
6 Replies
MSSQL_NUM_FIELDS(3)													       MSSQL_NUM_FIELDS(3)

mssql_num_fields - Gets the number of fields in result

SYNOPSIS
int mssql_num_fields (resource $result) DESCRIPTION
mssql_num_fields(3) returns the number of fields in a result set. PARAMETERS
o $result - The result resource that is being evaluated. This result comes from a call to mssql_query(3). RETURN VALUES
Returns the number of fields, as an integer. EXAMPLES
Example #1 mssql_num_fields(3) example <?php // Connect to MSSQL and select the database $link = mssql_connect('KALLESPCSQLEXPRESS', 'sa', 'phpfi'); mssql_select_db('php', $link); // Select some data from our database $data = mssql_query('SELECT [name], [age] FROM [php].[dbo].[persons]'); // Construct a table echo '<table border="1">'; $header = false; // Iterate through returned results while ($row = mssql_fetch_array($data)) { // Build the table header if (!$header) { echo '<thead>'; echo '<tr>'; for ($i = 1; ($i + 1) <= mssql_num_fields($data); ++$i) { echo '<td>' . ucfirst($row[$i]) . '</td>'; } echo '</tr>'; echo '</thead>'; echo '<tbody>'; $header = true; } // Build the row echo '<tr>'; foreach($row as $value) { echo '<td>' . $value . '</td>'; } echo '</tr>'; } // Close table echo '</tbody>'; echo '</table>'; // Clean up mssql_free_result($data); mssql_close($link); ?> SEE ALSO
mssql_query(3), mssql_fetch_field(3), mssql_num_rows(3). PHP Documentation Group MSSQL_NUM_FIELDS(3)
All times are GMT -4. The time now is 04:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy