Need Help : Improved command

Hello,

I need comment to improved function that will display this :

*****LISTE DES ATTRIBUTS DES FICHIERS*****
FILE='/OPERATIONNEL/SATURNE/PHY_MOD/NOW/SATURNE_1DAV_20110119_20110120_GRIDKZLN10_R20110126.NC                                                                                                                                                      ';;
 ARC_DATE='2011-02-02'
 ARC_TIME='08.43.00'
;;
STAS034  RC = 0 I Deroulement correct
*****

like this :

/OPERATIONNEL/SATURNE/PHY_MOD/NOW/;SATURNE_1DAV_20110119_20110120_GRIDKZLN10_R20110126.NC;2011-02-02

here is what I ve done

fort_ligne () {
     cpt=0
     while read line
     do
        if [ $(( ${cpt}%2 )) -eq 0 ]
        then
                prd=`echo ${line} | cut -c7-`
                prd_final=`basename $prd`
        else
                arc_date=`echo ${line} | cut -d"'" -f2`
                echo "${branche}/;${prd_final};${arc_date}" | tee -a ${fic_tmp_resultat}
        fi
        (( cpt=$cpt+1 ))
done <$1
}


cut -d" " -f1-2 | egrep '(FILE|ARC_DATE)' file > new_file

fort_ligne new_file

INFO : ${branche} = /OPERATIONNEL/SATURNE/PHY_MOD/NOW/

The function is working fine but I am not sure it's the best way to do it.

I hope you will be able to help me.

Thanks

$ cat sample10.txt
*****LISTE DES ATTRIBUTS DES FICHIERS*****
FILE='/OPERATIONNEL/SATURNE/PHY_MOD/NOW/SATURNE_1DAV_20110119_20110120_GRIDKZLN10_R20110126.NC
                                                                                                                ';;
 ARC_DATE='2011-02-02'
 ARC_TIME='08.43.00'
;;
STAS034  RC = 0 I Deroulement correct
*****
*****LISTE DES ATTRIBUTS DES FICHIERS*****
FILE='/OPERATIONNEL/SATURNE/PHY_MOD/NOW/SATURNE_1DAV_20110119_20110120_GRIDKZLN10_R20110126.NC
                                                                                                                ';;
 ARC_DATE='2011-02-03'
 ARC_TIME='08.43.00'
;;
STAS034  RC = 0 I Deroulement correct
*****

$ cat sample10.txt | grep -v "^*" | sed "s/FILE/~FILE/g" | tr "\n" ";" | tr "~" "\n" | tr -d " " | tr -d "'" | cut -d";" -f1,4

FILE=/OPERATIONNEL/SATURNE/PHY_MOD/NOW/SATURNE_1DAV_20110119_20110120_GRIDKZLN10_R20110126.NC;ARC_DATE=2011-02-02
FILE=/OPERATIONNEL/SATURNE/PHY_MOD/NOW/SATURNE_1DAV_20110119_20110120_GRIDKZLN10_R20110126.NC;ARC_DATE=2011-02-03

Another way:

sed -n "/^FILE/{N;s/FILE='//;s/ .*\n ARC_DATE='/;/;s/'$//;p;}" inp_file

Dear Shell_Life,

thanks a lot for your help. Your code is working fine, BUT here is your OUTPUT :

/OPERATIONNEL/SATURNE/PHY_MOD/NOW/SATURNE_1DAV_20110119_20110120_GRIDKZLN10_R20110126.NC;2011-02-02

But I need this :

/OPERATIONNEL/SATURNE/PHY_MOD/NOW/;SATURNE_1DAV_20110119_20110120_GRIDKZLN10_R20110126.NC;2011-02-02

As you can see I need an

;

at the begining of the file name. Do you think you could add this on your command line ?

Thanks

Note the highlighted code:

sed -n "/^FILE/{N;s/FILE='//;s/ .*\n ARC_DATE='/;/;s/'$//;s#\(.*\)/#\1;#;p;}" 

Dear Shell_Life,

I try to use the command line. I succed to modified the line to make the ouput as I need.

Here is my code modified.

Note the highlighted code:

sed -n "/^FILE/{N;s/FILE='//;s/ .*\n ARC_DATE='/;/;s/'$//;s#\(.*\)/#\1/;#;p;}"

I did it because the result was not like the result post as needed.

My needs :

/OPERATIONNEL/SATURNE/PHY_MOD/NOW/;SATURNE_1DAV_20110119_20110120_GRIDKZLN10_R20110126.NC;2011-02-02

your result :

/OPERATIONNEL/SATURNE/PHY_MOD/NOW;SATURNE_1DAV_20110119_20110120_GRIDKZLN10_R20110126.NC;2011-02-02

do you mind to tell me if my change is correct. I did not want to change the last

 / 

by this

 ; 

I just wanted to add it to it.

Thanks

Your change works.

Another way is:
(Note the forward highlighted forwarded slash)

sed -n "/^FILE/{N;s/FILE='//;s/ .*\n ARC_DATE='/;/;s/'$//;s#\(.*/\)#\1;#;p;}"