Hi,
Is it possible to use one script to perform a different nawk processing sequence depending on the input file?
In order to use only one script to process several files with different formats.
For example, I cut the first 4 colums out of a log file, either a.txt or b.txt depending on which file is used then use nawk to parse the log.
#! /bin/sh
{
if (inputfile = a.txt)
cut -d" " -f1,2,3,4 a.txt
else
cut -d" " -f1,2,3,4 b.txt
fi
} | nawk '
BEGIN { (some pre-processing) }
if (inputfile = a.txt)
process1()
else if (inputfile = b.txt)
process2()
process1()
{
print hello
}
process2()
{
print goodbye
}
END { (some post-processing) }'
Any help will be great,
Thanks,
uksnowman
Is it possible to use one script to perform a different nawk processing sequence depending on the input file?
In order to use only one script to process several files with different formats.
For example, I cut the first 4 colums out of a log file, either a.txt or b.txt depending on which file is used then use nawk to parse the log.
#! /bin/sh
{
if (inputfile = a.txt)
cut -d" " -f1,2,3,4 a.txt
else
cut -d" " -f1,2,3,4 b.txt
fi
} | nawk '
BEGIN { (some pre-processing) }
if (inputfile = a.txt)
process1()
else if (inputfile = b.txt)
process2()
process1()
{
print hello
}
process2()
{
print goodbye
}
END { (some post-processing) }'
Any help will be great,
Thanks,
uksnowman