Trying to read in a file line at a time, and output each entry to a text file in different order.

From: Tonij (tonij67_at_hotmail.com)
Date: 07/02/04


Date: 2 Jul 2004 06:17:15 -0700

I can't figure out whats wrong with my script.

I am trying to read in a file that has multiple lines in this format:

(cat dflist)
/dev/dsk/c1t0d0s0 /
/dev/dsk/c1t0d0s4 /usr
/dev/dsk/c1t0d0s3 /var

What I am after is output similar to this:

Service Description: /
CheckCommand: /dev/dsk/c1t0d0s0
Service Description: /usr
CheckCommand:/dev/dsk/c1t0d0s4
Service Description: /var
CheckCommand:/dev/dsk/c1t0d0s3
etc...

Here is what I have so far:

#!usr/bin/ksh

for fs in `cat dflist`
do
  Service=`echo $fs | awk '{print $1}'`
  CheckCommand=`echo $fs | awk '{print $2}'`
  echo "Service Description:" $Service
  echo "CheckCommand:" $CheckCommand
done

This is what I am getting when I run it:

Service Description: /dev/dsk/c1t0d0s0
CheckCommand:
Service Description: /
CheckCommand:
Service Description: /dev/dsk/c1t0d0s4
CheckCommand:
Service Description: /usr
CheckCommand:
Service Description: /dev/dsk/c1t0d0s3
CheckCommand:
Service Description: /var
CheckCommand:

What am I doing wrong? This seems like it should be simple but for
the life of me I cannot get the fields in the right place.

Any info appreciated,



Relevant Pages