#!/usr/bin/env zsh
LANG=C LC_ALL=C
export LANG LC_ALL
num_part=$1 # parametre en la linia de comandament, particula a cercar
print "\#Eix semimajor i excentricitat de la particula $num_part"
print "\#Col1:t Col2:a Col3:e..ncara no fet"
for fitxer in $( ls Splotch*_part.asc ); do;
# Cerquem les dades del fn, M, X, Y i Z
Mfn = $( grep " 1 " $fitxer | gawk '{print $2}' )
Xfn = $( grep " 1 " $fitxer | gawk '{print $3}' )
Yfn = $( grep " 1 " $fitxer | gawk '{print $4}' )
Zfn = $( grep " 1 " $fitxer | gawk '{print $5}' )
# Calculem l'eix semimajor del sistema 1-particula
cat $fitxer | gawk -v XFN=$Xfn -v YFN=$Yfn -v ZFN=$Zfn -v MFN=$Mfn -v NAME=$num_part '
/AS/ {TIME=$4}
$1==NAME {print TIME,(sqrt(($3-XFN)^2+($4-YFN)^2+($5-ZFN))*MFN/(2*MFN-$11*($6^2+$7^2+$8^2))); exit}
'
done
... the result
elachistos| ./Semi_i_Excentr.sh 2
#Eix semimajor i excentricitat de la particula 2
#Col1:t Col2:a Col3:e..ncara no fet
./Semi_i_Excentr.sh:15: command not found: Mfn
./Semi_i_Excentr.sh:16: command not found: Xfn
./Semi_i_Excentr.sh:17: command not found: Yfn
./Semi_i_Excentr.sh:18: command not found: Zfn
0.00000E+00 0
./Semi_i_Excentr.sh:15: command not found: Mfn
./Semi_i_Excentr.sh:16: command not found: Xfn
./Semi_i_Excentr.sh:17: command not found: Yfn
./Semi_i_Excentr.sh:18: command not found: Zfn
0.10000E+01 0
./Semi_i_Excentr.sh:15: command not found: Mfn
./Semi_i_Excentr.sh:16: command not found: Xfn
./Semi_i_Excentr.sh:17: command not found: Yfn
./Semi_i_Excentr.sh:18: command not found: Zfn
BTW what do you recommend me to learn? perl or python or ruby? I am a bit fed up that this scripting is so strict... I feel like programming in fortran (what I also do )
Usually I have to do this kind of operations and sometimes the data blocks are up to 128000 lines with eight or more columns... and I have usually about 2500 data files like that... in total sometimes about 6GB/2500 files
So what'd be faster and easier to apply/learn, python, perl, ruby??