I have set an export X25DATAF=/home/Bob/X25/Datafiles
in my profile and that's what is outputted when I do a echo $X25DATAF
.
I want to replace /home/Bob/X25/Datafiles
in the awk
below with the $X25DATAF
in the 2 places it's in the awk
program. But, I can't get it to work (ie: $X25DATAF/ALL_SW_DB.txt
). This way all I have to do is set the export
to the path on whichever system I'm on to run this awk
program (and others like it).
awk -F"\t" '
FILENAME=="Sites1" {
cllina[$0]=$0
}
FILENAME=="/home/bob/X25/DataFiles/ALL_SW_DB.txt" {
swclli=hostclli=""
swclli=substr($7,1,8)
hostclli=substr($3,1,8)
fclli[hostclli]++
fclli[swclli]++
if(hostclli==cllina[hostclli]) {
if(swclli!=hostclli) {
printf"REM|%s|%s|%s|%s|%s|%s|%s|%s|%s-%s\n",hostclli,$4,$3,$6,$9,$7,$12,$13,$5,$14 >>"host_remote"
}
}
if(swclli==cllina[swclli]) {
printf"HOST|%s|%s|%s|%s|%s|%s|%s|%s|%s-%s\n",swclli,$4,$3,$6,$9,$7,$12,$13,$5,$14 >>"host_remote"
}
}
END{
for(x in cllina)
if(fclli[x]=="") printf"%s\n",x >"site1.err"
}' Sites1 /home/bob/X25/DataFiles/ALL_SW_DB.txt
FILENAME!="Sites1"
. Or use the awk variableARGIND
which says which file you are looking at, 1 or 2.ARGV[2]
inawk
program to get/home/bob/X25/DataFiles/ALL_SW_DB.txt
, you passed it as second argument to yourawk
.