Tuesday 15 March 2011

bash - identify error in if statement -


This is a complete code ..

What am I trying to do ->

I am trying to find the average of values ​​in the second column of files. If the file has 2.54 names in it, then I want to get the file from average in files related to the file. File 054_even.xls and file_2.54_odd.xls. If there is no 2.54 on the name of Faynm, then just the average of the file is revealed. For example: file_1.60.xls

  #! / Bin / bash file in pmb_mpi tau xhpl mpi_tile_io fftw; For 2.54 1.60 800, if $ $ {f} = "2.54"] then $ {file} _ $ {f} _even_v1.xls esk 'yoga = $ 2; Ed {print "avg =", $ sum / nr> $ {File} _ $ {f} _avrg.xls} '$ {file} _ $ {f} _even_v1.xls resonant $ {file} _ $ {f} _odd_v1.xls awk' sum + = $ 2; END {print "average =", $ yoga / nr> gt; $ {File} _ $ {f} _avrg.xls} '$ {file} _ $ {f} _odd_v1.xls else echo $ {file} _ $ {f} _v1.xls awk' sum + = $ 2; END {print "average =", $ yoga / nr> gt; $ {File} _ $ {f} _avrg.xls} '$ {file} _ {f} _v1.xls foo  

Because your awk command is inside a single quotes, the shell variable file and f will not be be extended. That's why you are getting awk errors.

I will use the following script:

  #! PMBMP Tau XHPP MPI_Tile_OFFTV for file in / bin / bash; 2.54 For 1.60 f; If [[$ {F} = "2.54"] ;; Then flist = $ {file} _ $ {f} _even_v1.xls $ {file} _ $ {f} _odd_v1.xls and flists = $ {file} _ $ {f} _v1.xls fi $ {flist} | Awk 's + = $ 2; $ {File} _ $ {print "average =", $ s / nr} '& gt; Use $ {file} _ $ {f} _avrg.xls # or awk ... '$ {flist} & gt; F} _avrg.xls # If you are very worried about the efficiency of the procedures  f   2.54      < / Code>    / code> or not, then push the list of files through a single  awk  script. 


No comments:

Post a Comment