5/25/2022

Seismic ghost notch calculation

 

where  is the source or receiver depth in meters

print one column after another

 guofyuan @ htpvis-025a$ cat test.txt
AAA    111  123
BBB    222  234
CCC    333  345

guofyuan @ htpvis-025a$ awk '{if(maxc<NF)maxc=NF; for(i=1;i<=NF;i++){(a[i]!=""?a[i]=a[i]RS$i:a[i]=$i)} } END{for(i=1;i<=maxc;i++)print a[i]}' test.txt
AAA
BBB
CCC
111
222
333
123
234
345

 

 gawk '{for (i=1; i<=NF; i++) # loop over columns

           data[i][NR]=$i               # store in data[column][line]
      }
      END {for (i=1;i<=NR;i++)          # loop over lines
                for (j=1;j<=NF;j++)     # loop over columns
                     print data[i][j]   # print the given field
      }' file

https://stackoverflow.com/questions/39287224/how-to-print-columns-one-after-the-other-in-bash

5/20/2022

convert a horizontal file to vertical one using awk

 $ cat TBB11-str-ghost-far-tmp.txt | awk '{for(i=1;i<=NF;i++) {print $i}}'


Input

guofyuan @ htpvis-025a$ head TBB11-str-ghost-far-tmp.txt
     0.000     0.000     0.000     0.000     0.000     0.000    -0.001
     0.001    -0.001    -0.002     0.007    -0.013     0.016    -0.012
    -0.006     0.038    -0.076     0.100    -0.087     0.014     0.118
    -0.278     0.401    -0.403     0.213     0.193    -0.762     1.365
    -1.808     1.865    -1.235    -0.757    50.286    57.557     5.330
     5.619   -27.954  -110.350   -86.889   -19.798    -6.313    21.974
    52.920    32.938     6.974     1.216     2.681     6.191     4.807
     2.697     1.438    -0.089     0.905     1.381     0.864     0.263
     0.096     0.493     0.419     0.371     0.348     0.237     0.287
     0.396     0.447     0.389     0.383     0.459     0.519     0.553

output
guofyuan @ htpvis-025a$ head TBB11-str-ghost-far-vertical.txt
0.000
0.000
0.000
0.000
0.000
0.000
-0.001
0.001
-0.001
-0.002

5/02/2022

count the frequency of a list (uniq -c)

 guofyuan @ htpvis-025a$ ls Seq* | nl | sed 's/_Subline_/ /g' | sed 's/Seq//g' | awk '{print $2'} | uniq -c | awk '$1<4'

      3 125