| 
            Last change
 on this file since 76b3dc was             77f1ae, checked in by Frederik Heber <heber@…>, 18 years ago           | 
        
        
          | 
             
exit statement missing if command line options were missing 
 
"exit 1" added to if then else statement 
 
           | 
        
        
          
            
              - 
Property                 mode
 set to                 
100755
               
             
           | 
        
        
          | 
            File size:
            954 bytes
           | 
        
      
      
| Line |   | 
|---|
| 1 | #!/bin/sh
 | 
|---|
| 2 | #
 | 
|---|
| 3 | # extracts a .xyz-file from a pcp config file
 | 
|---|
| 4 | 
 | 
|---|
| 5 | if [ -z "$1" ]; then
 | 
|---|
| 6 |         echo "Usage: $0 <config> [output.xyz]"
 | 
|---|
| 7 |         exit 1
 | 
|---|
| 8 | else
 | 
|---|
| 9 |         config=$1
 | 
|---|
| 10 |         if [ ! -z "$2" ]; then
 | 
|---|
| 11 |                 output=$2
 | 
|---|
| 12 |         else
 | 
|---|
| 13 |                 output="$1.xyz"
 | 
|---|
| 14 |         fi
 | 
|---|
| 15 | fi
 | 
|---|
| 16 | 
 | 
|---|
| 17 | echo -n "Retrieving Ion types ..."
 | 
|---|
| 18 | ions=`grep '^Ion_Type.[^_]' $config | awk -F"\t" {'print $9'}`
 | 
|---|
| 19 | ionnumber=`grep '^Ion_Type.[^_]' $config | awk -F"\t" {'print $2'}`
 | 
|---|
| 20 | OLDIFS=$IFS
 | 
|---|
| 21 | IFS='
 | 
|---|
| 22 | '
 | 
|---|
| 23 | i=1
 | 
|---|
| 24 | number=0
 | 
|---|
| 25 | declare -a types
 | 
|---|
| 26 | for ion in $ions; do
 | 
|---|
| 27 |         types[$i]=$ion
 | 
|---|
| 28 |         let i=$i+1
 | 
|---|
| 29 | done
 | 
|---|
| 30 | i=1
 | 
|---|
| 31 | for nr in $ionnumber; do
 | 
|---|
| 32 |         let number=$number+$nr
 | 
|---|
| 33 |         echo -n "${types[$i]} ($nr)"
 | 
|---|
| 34 |         let i=$i+1
 | 
|---|
| 35 | done
 | 
|---|
| 36 | IFS=$OLDIFS
 | 
|---|
| 37 | echo done
 | 
|---|
| 38 | 
 | 
|---|
| 39 | echo "Converting $config to $output...done"
 | 
|---|
| 40 | # Schreibe Kopf
 | 
|---|
| 41 | echo "$number" >$output
 | 
|---|
| 42 | echo -e "\tgenerated with config2xyz from $config" >>$output
 | 
|---|
| 43 | # Fuege Ionen dran
 | 
|---|
| 44 | j=1
 | 
|---|
| 45 | while [ $j -lt $i ]; do
 | 
|---|
| 46 |         `grep ^Ion_Type${j}_ $config | awk -F" " {'print $1"\t"$2"\t"$3"\t"$4'} | sed -e "s#Ion_Type${j}_[0-9]*#${types[$j]}#" >>$output`
 | 
|---|
| 47 |         let j=$j+1
 | 
|---|
| 48 | done
 | 
|---|
| 49 | 
 | 
|---|
| 50 | 
 | 
|---|
| 51 | exit 0
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.