Thread: Change EVLA and EVLO taking values from another file

Started: 2013-08-16 23:59:35
Last activity: 2013-08-21 05:03:26
Topics: SAC Help
Tannistha Maiti
2013-08-16 23:59:35
Hello,

I would like to modify the EVLA and EVLO values in the header using bash
script. The lat and long values are stored in coord.txt file. I used the
following script but not sure why it is not reading from the file. The
coord file contains two values column 1 lat and column 2 long.

#bin/bash!
saclst evlo evla f|awk '{a+=$1} {b+=$2} {printf "r
NET.STA1216..BXE.sac\nch %f %f \nwh\nq\n",a,b} END{print "quit"}' | sac
coord.txt

However this command works.
printf "r NET.STA1216..BXE.sac\nch evlo 100 evla 100 \nwh\nq\n" | sac

Thanks,
Tannistha

  • Try this,

    #!/bin/bash
    saclst evlo evla f test.sac
    awk '{printf "r test.sac\nch evlo %f evla %f\nwh\nq\n",$1,$2}' coord | sac
    saclst evlo evla f test.sac



    2013/8/17 Tannistha Maiti <titli<at>vt.edu>

    Hello,

    I would like to modify the EVLA and EVLO values in the header using bash
    script. The lat and long values are stored in coord.txt file. I used the
    following script but not sure why it is not reading from the file. The
    coord file contains two values column 1 lat and column 2 long.

    #bin/bash!
    saclst evlo evla f|awk '{a+=$1} {b+=$2} {printf "r
    NET.STA1216..BXE.sac\nch %f %f \nwh\nq\n",a,b} END{print "quit"}' | sac
    coord.txt

    However this command works.
    printf "r NET.STA1216..BXE.sac\nch evlo 100 evla 100 \nwh\nq\n" | sac

    Thanks,
    Tannistha

    _______________________________________________
    sac-help mailing list
    sac-help<at>iris.washington.edu
    http://www.iris.washington.edu/mailman/listinfo/sac-help



    • Tannistha Maiti
      2013-08-20 18:18:31
      Hi ,

      The above command helps but I would like to pass the file name from the
      command prompt. However this code is not reading the files. $1 is the
      filename. The awk command cannot read the file.
      #!/bin/bash
      file="$1"
      saclst evlo evla f "$file"
      awk '{printf "r "$file"\nch evlo %f evla %f\nwh\nq\n",$1,$2}' coord.txt |
      sac
      saclst evlo evla f "$file"

      Thanks,
      Tannistha



      On Fri, Aug 16, 2013 at 11:26 PM, Dongdong Tian <seisman.ustc<at>gmail.com>wrote:

      Try this,

      #!/bin/bash
      saclst evlo evla f test.sac
      awk '{printf "r test.sac\nch evlo %f evla %f\nwh\nq\n",$1,$2}' coord | sac
      saclst evlo evla f test.sac



      2013/8/17 Tannistha Maiti <titli<at>vt.edu>

      Hello,

      I would like to modify the EVLA and EVLO values in the header using bash
      script. The lat and long values are stored in coord.txt file. I used the
      following script but not sure why it is not reading from the file. The
      coord file contains two values column 1 lat and column 2 long.

      #bin/bash!
      saclst evlo evla f|awk '{a+=$1} {b+=$2} {printf "r
      NET.STA1216..BXE.sac\nch %f %f \nwh\nq\n",a,b} END{print "quit"}' | sac
      coord.txt

      However this command works.
      printf "r NET.STA1216..BXE.sac\nch evlo 100 evla 100 \nwh\nq\n" | sac

      Thanks,
      Tannistha

      _______________________________________________
      sac-help mailing list
      sac-help<at>iris.washington.edu
      http://www.iris.washington.edu/mailman/listinfo/sac-help




      • Milton Plasencia
        2013-08-21 05:03:26
        Hi,

        Try it:

        ***************
        #!/bin/bash

        file=$1
        saclst evlo evla f $file
        awk -v p=$file '{printf "r "p"\nch evlo %f evla %f\nwh\nq\n",$1,$2}' coord.txt | sac
        saclst evlo evla f $file
        *****************

        HTH,

        * * * * * * * * * * * * * * * * * * * * * * *
        Milton P. PLASENCIA LINARES

        Centro di Ricerche Sismologiche (CRS)
        OGS - Istituto Nazionale di Oceanografia
        e di Geofisica Sperimentale

        Borgo Grotta Gigante 42/C
        (34010) Sgonico - Trieste - Italia
        Tel: +39 040 2140 141 (Udine)
        Tel: +39 040 2140 256 (Trieste)
        Cel.: +39 331 6481 935
        Fax: +39-040-327307

        E-mail: mplasencia<at>inogs.it

        ASAIN (Antarctic Seismographic Argentinean Italian Network)
        *********************************










        On Aug 20, 2013, at 7:18 PM, Tannistha Maiti <titli<at>vt.edu> wrote:

        Hi ,

        The above command helps but I would like to pass the file name from the command prompt. However this code is not reading the files. $1 is the filename. The awk command cannot read the file.
        #!/bin/bash
        file="$1"
        saclst evlo evla f "$file"
        awk '{printf "r "$file"\nch evlo %f evla %f\nwh\nq\n",$1,$2}' coord.txt | sac
        saclst evlo evla f "$file"

        Thanks,
        Tannistha



        On Fri, Aug 16, 2013 at 11:26 PM, Dongdong Tian <seisman.ustc<at>gmail.com> wrote:
        Try this,

        #!/bin/bash
        saclst evlo evla f test.sac
        awk '{printf "r test.sac\nch evlo %f evla %f\nwh\nq\n",$1,$2}' coord | sac
        saclst evlo evla f test.sac



        2013/8/17 Tannistha Maiti <titli<at>vt.edu>
        Hello,

        I would like to modify the EVLA and EVLO values in the header using bash script. The lat and long values are stored in coord.txt file. I used the following script but not sure why it is not reading from the file. The coord file contains two values column 1 lat and column 2 long.

        #bin/bash!
        saclst evlo evla f|awk '{a+=$1} {b+=$2} {printf "r NET.STA1216..BXE.sac\nch %f %f \nwh\nq\n",a,b} END{print "quit"}' | sac coord.txt

        However this command works.
        printf "r NET.STA1216..BXE.sac\nch evlo 100 evla 100 \nwh\nq\n" | sac

        Thanks,
        Tannistha

        _______________________________________________
        sac-help mailing list
        sac-help<at>iris.washington.edu
        http://www.iris.washington.edu/mailman/listinfo/sac-help



        _______________________________________________
        sac-help mailing list
        sac-help<at>iris.washington.edu
        http://www.iris.washington.edu/mailman/listinfo/sac-help


01:27:33 v.22510d55