#!/bin/gawk -f # # areas prints the unique areas (IN20, LI22 etc) in a beamline, as emitted by # aida "modelTwiss" queries. In general, any file where column 3 is a list # of device names that contain area names may be used. # # Usage: # aidaget modelTwiss//Design.FullMachine | awk -W re-interval -f areas # # Rem: awk option "re-interval" is required for use of {n} repetition syntax. # BEGIN { IN = "(IN[[:digit:]]{2})"; LI = "(LI[[:digit:]]{2})"; BSY = "(BSY[[:digit:]])"; CA = "(CA[[:digit:]]{2})"; LTU = "(LTU[[:digit:]])"; UND = "(UND[[:digit:]])"; DMP = "(DMP[[:digit:]])"; } $3 ~ (IN) { addarea($3,IN); next } $3 ~ (LI) { addarea($3,LI); next } $3 ~ (BSY) { addarea($3,BSY); next } $3 ~ (CA) { addarea($3,CA); next } $3 ~ (LTU) { addarea($3,LTU); next } $3 ~ (UND) { addarea($3,UND); next } $3 ~ (DMP) { addarea($3,DMP); next } function addarea(device,regionpattern) { s=match(device,regionpattern); r = substr($3,s,RLENGTH); if ( areas[r] != 1) { print r; areas[r]=1; } }