Hi.
I had to change the sub like so, from quote to slash:
Code:
#!/usr/bin/env sh
# @(#) user1 Demonstrate 2-level parsing with awk.
# ____
# /
# | Infrastructure BEGIN
set -o nounset
echo
## The shebang using "env" line is designed for portability. For
# higher security, use:
#
# #!/bin/sh -
## Use local command version for the commands in this demonstration.
set +o nounset
echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version "=o" $(_eat $0 $1) awk
set -o nounset
echo
FILE=${1-data1}
echo " Input file $FILE:"
cat $FILE
# Use nawk or /usr/xpg4/bin/awk on Solaris.
# | Infrastructure END
# \
# ---
echo
echo " Results from awk:"
awk -F, '
/^Personal Unit=/ && /Plant/ && /Departmant/ {sub(/\(.*\)/,"")}
{print $1 OFS $2 OFS $3}
' OFS="\n" $FILE
exit 0
Producing:
Code:
% ./user1
(Versions displayed with local utility "version")
Linux 2.6.11-x1
GNU bash, version 2.05b.0(1)-release (i386-pc-linux-gnu)
GNU Awk 3.1.4
Input file data1:
Personal Unit=AU003 (Industrial Products Division),Plant=B00089,Departmant=D110
Results from awk:
Personal Unit=AU003
Plant=B00089
Departmant=D110
cheers, drl
|