source: util/config2xyz.sh@ dac5c5

Last change on this file since dac5c5 was 77f1ae, checked in by Frederik Heber <heber@…>, 17 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
5if [ -z "$1" ]; then
6 echo "Usage: $0 <config> [output.xyz]"
7 exit 1
8else
9 config=$1
10 if [ ! -z "$2" ]; then
11 output=$2
12 else
13 output="$1.xyz"
14 fi
15fi
16
17echo -n "Retrieving Ion types ..."
18ions=`grep '^Ion_Type.[^_]' $config | awk -F"\t" {'print $9'}`
19ionnumber=`grep '^Ion_Type.[^_]' $config | awk -F"\t" {'print $2'}`
20OLDIFS=$IFS
21IFS='
22'
23i=1
24number=0
25declare -a types
26for ion in $ions; do
27 types[$i]=$ion
28 let i=$i+1
29done
30i=1
31for nr in $ionnumber; do
32 let number=$number+$nr
33 echo -n "${types[$i]} ($nr)"
34 let i=$i+1
35done
36IFS=$OLDIFS
37echo done
38
39echo "Converting $config to $output...done"
40# Schreibe Kopf
41echo "$number" >$output
42echo -e "\tgenerated with config2xyz from $config" >>$output
43# Fuege Ionen dran
44j=1
45while [ $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
48done
49
50
51exit 0
Note: See TracBrowser for help on using the repository browser.