#!/bin/csh
#
# data extractor
#

set lat = "60 22.77700N"
set lon = "42 54.63700W"

foreach file ( `ls` )
   echo $file
   set clat = `awk '$1=="Latitude" {printf "%s %s",$3,substr($4,1,length($4)-1)}' $file`
   set clon = `awk '$1=="Longitude" {printf "%s %s",$3,substr($4,1,length($4)-1)}' $file`
   # set clat = `cat $file | awk '$1=="Latitude" {printf "%s %s",$3,substr($4,1,length($4)-1)}'`
   # set clon = `cat $file | awk '$1=="Longitude" {printf "%s %s",$3,substr($4,1,length($4)-1)}'`
   if (`echo $lat` == `echo $clat` && `echo $lon` == `echo $clon`) then
      set sl = `cat $file | awk '{if (NR>40 && $1=="//") print NR}'`
      # set sl = `cat $file | awk '{if (NR>40 && $1~/\/\//) print NR}'`
      awk -v sl=$sl 'NR>sl {print}' $file > $file:t:r_ext.txt
      # cat $file | awk -v sl=$sl 'NR>sl {print}' > $file:t:r_ext.txt
   endif
end

'Software > Shell script' 카테고리의 다른 글

[Linux/shell/bash/csh] shell 스크립트 튜토리얼  (0) 2020.01.20

+ Recent posts