#!/bin/sh # # extracts a .xyz-file from a pcp config file if [ -z "$1" ]; then echo "Usage: $0 [output.xyz]" exit 1 else config=$1 if [ ! -z "$2" ]; then output=$2 else output="$1.xyz" fi fi echo -n "Retrieving Ion types ..." ions=`grep '^Ion_Type.[^_]' $config | awk -F"\t" {'print $9'}` ionnumber=`grep '^Ion_Type.[^_]' $config | awk -F"\t" {'print $2'}` OLDIFS=$IFS IFS=' ' i=1 number=0 declare -a types for ion in $ions; do types[$i]=$ion let i=$i+1 done i=1 for nr in $ionnumber; do let number=$number+$nr echo -n "${types[$i]} ($nr)" let i=$i+1 done IFS=$OLDIFS echo done echo "Converting $config to $output...done" # Schreibe Kopf echo "$number" >$output echo -e "\tgenerated with config2xyz from $config" >>$output # Fuege Ionen dran j=1 while [ $j -lt $i ]; do `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` let j=$j+1 done exit 0