I have the data file which looks like that
I've been using the following code to extract numerical data for let say entry 350 from the file called data
I put it in my ~/bin and run it like
and it will spit me the desired formated columns of data for the given entry.
Is there a way to merge the three awk '{...}' into one only without the need to write those tmp files to the disk .
I have this kind of problem in number of my scripts since I am not very fluent in awk and I usually write them in a hurry to get things done.
I am trying to put some more time in learning awk and sounds like learning pearl in the long run will be quite beneficial for my kind of work
Code:
#S 1 …............
#D Tue ….......
…....................
…....................
#S 350 a2scan oh -4.42031 -3.62031 or 0.298354 0.381046 28 -600000
#D Tue Feb 17 05:02:03 2009
#P7 S4L S4R S5L S5R S6_GAP S6_CEN
# 1 1 12 12 4.99987 2.89827e-05
#W 0.413280
#A 0
#N 16
#L
-4.4201082 0.29839999 0 6.05517e-05 0.169237 200205 3.253e+06 2.43859e+06 0 1 0 0 1 29.7685 600000 307
-4.3921682 0.30119999 0 5.66641e-05 0.16998 200236 3.24289e+06 2.43264e+06 0 1 0 0 1 29.6072 600000 326
-3.6494722 0.37829999 0 -6.46472e-05 0.190438 201044 3.22599e+06 2.42768e+06 0 1 0 0 1 29.6273 600000 262
-3.6202622 0.38109999 0 -6.95709e-05 0.191181 201075 3.23008e+06 2.43027e+06 0 1 0 0 1 29.6994 600000 288
Peak at -4.13461 is 442 COM at -4.02685 FWHM is 0 at -4.13461
Sum = 10097 Ave.Mon./Time = 29.7028 Ave.Temp. = 0C
#S 351 a2scan oh -4.42031 -3.62031 or 0.298654 0.381346 28 -600000
#D Tue Feb 17 05:22:03 2009
…...........
…...........
I've been using the following code to extract numerical data for let say entry 350 from the file called data
Code:
#/bin/bash
SN1="#S $2 "
awk "/$SN1/,/Peak/{print}" $1|awk '!/[f-z]|#|^$/' >/tmp/data.tmp
awk '{printf("%-2.5e %-1.5e %1.5e \n", $1 ,$NF/$(NF-1), $NF/$(NF-1)*sqrt(1/($NF) + 1/($(NF-1))) )}' /tmp/datama.tmp >/tmp/datama
cat /tmp/datama
I put it in my ~/bin and run it like
Code:
$executable.sh data 350
Is there a way to merge the three awk '{...}' into one only without the need to write those tmp files to the disk .
I have this kind of problem in number of my scripts since I am not very fluent in awk and I usually write them in a hurry to get things done.
I am trying to put some more time in learning awk and sounds like learning pearl in the long run will be quite beneficial for my kind of work