Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

don't process last line

Status
Not open for further replies.

longhair

MIS
Feb 7, 2001
889
US
afternoon all,
hpux11
based on the following:
Code:
cat /files/dsdcwhd.txt | while read dcoff dctty dcmnth dcday dctime
  do
   finger -i |grep $dctty >> /files/dsdcwhd1.txt
  done
is there a graceful way to not process a line? within dsdcwhd.txt i do not want to process the last line, it does not contain an entry for dctty and therefore throws an error when passed to grep.
thanks in advance.
regards,
longhair
 
ok - think i have it but am a little confused...
Code:
cat /files/dsdcwhd.txt | while read dcoff dctty dcmnth dcday dctime
  do
    if
      test -n $dctty
    then
      finger -i |grep $dctty >> /files/dsdcwhd1.txt
    fi
  done
this will only process the finger line if dctty contains a value.
however when i run the script manually it returns
./dcoffend[15]: test: Specify a parameter with this command
although the output is correct an d the rest of the script process correct.
any reason?
regards,
longhair
 
never mind - found it..
test -n "$dctty"
regards,
longhair
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top