Using AWK to format output and email

Hello,

I'm a bit stumped, for some reason when using AWK 'print' is not printing the entire date/line.

awk '{print "Ticket #: " $1}
         {print "Queue : " $2}
         {print "Recieved : " $3}
         {print "AP Date : " $4}
         {print "Circuit ID : " $5}
         {print "Customer Name : " $6}' $FBLOG >$FBLOG.1

In the issue is the "Customer Name" for some reason its only printing the first word of the customer name.

Example ...

If the customer name is "ABC Company", it will only print "ABC"

Any help is apprieciated,

awk by default separates fields on whitespace. How is it supposed to tell a 'good' space you do want, apart from a 'bad' space you don't want? Your customer is getting broken into fields $6, $7, $8...

I'd try this in shell instead, which can be told to do a limited amount of splitting. Since there's no fields beyond CUSTOMER, everything after that point will go into the CUSTOMER variable.

while read TICKET QUEUE RECEIVED APDATE CIRCUIT CUSTOMER
do
        echo "Ticket # $TICKET"
        echo "Received $RECEIVED"
        ...
done < $FBLOG > $FBLOG.1
1 Like

Hi
Please provide a sample input file to understand the input better. With what you have put, the output seems to be in the expected lines. Since there is a space between the first and the last name, it will be treated as two separate fields meaning ABC is $6 and company as $7.

Guru.

1 Like

default separator for awk if space. So your 6th field is "ABC" and 7th is "Company".
Print 6th and 7th both while pulling Customer Name

1 Like

You guys rock! .... i didn't realize that the default separator for awk is "space"

I revised the code to now read as

{print "Customer Name : " $6, $7, $8}' $FBLOG >$FBLOG.1
 

and it works !