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 gibt es KINOFILM gleich zweimal OHNE '' als erstes Zeichen einer Zeile. Die Bedingung sollte greifen und ich springe in die folgende Anweisung XY:

Ich w�rde nun mit
"cat Kino.ini| grep KINOFILM >> tmp_KINOFILM"
alle Zeilen mit KINOFILM in eine Zwischendatei speichern

  • KINOFILM A
    KINOFILM B
    KINOFILM C

Ich habe nun aber folgende Probleme, da ich nur ein Bi�chen ksh kann, aber nicht bsh:

  1. Wie kann ich die Zeilen der Datei "tmp_KINOFILM" in ein VARIABEL langes / dynamisch allokiertes Array schreiben? (Es k�nnen mal 3, mal 5 oder 100 KINOFILME sein)
  2. Wie kann ich das erste Zeichen eines Arrayelementes pr�fen, ob es ein '*' ist?

Jetzt schon einmal vielen Dank f�r jede hilfreiche Antwort

Hello.

Per our forum rules, all posts must be in English.

We do provide translation services for posts from English to a number of languages as a benefit to users. However, posts must be in English.

Please repost in English.

Thank you for your cooperation.

The UNIX and Linux Forums.

Hello,

i have a file "Movie.ini" looking e.g. like follows

  • MOVIE A
    bla bla
    MOVIE B
    blubb blubb
    MOVIE C

I'd like to read the file "Movie.ini" with cat and grep and check whether it includes the string MOVIE only with a '*' at the beginnig.

By doing
"cat Movie.ini| grep MOVIE >> tmp_MOVIE "
all rows containing MOVIE should be saved in a tempfile

  • MOVIE A
    MOVIE B
    MOVIE C

I have following problem, since I just know a bit ksh but not bsh:

  1. How can I read out the rows of the file "tmp_MOVIE" in a VARIABLE long / dynamic allocated array? (Since there is NOT a fix number of rows containing the string MOVIE - it can be 3, 5 or e.g. 20)
  2. How can I check the first literal of an array-element whether it is a '*'?

Thanks a lot for any helpful answer

Semi double post - continue here: