using sed

William Lewis wiml at blake.acs.washington.edu
Mon Dec 18 09:54:13 AEST 1989


In article <14404 at eerie.acsu.Buffalo.EDU> kwon at sybil.cs.Buffalo.EDU (Thomas Kwon) writes:
>I want to extract the string "1.34" which is in "column 8" of "line 6"
>and set that to a variable. How can this be done?
>So far, I've been experimenting with : 
>
>     set string=`ruptime|sed  <Then I got stuck here>`

  Alternatively you could use 'cut' to slice out the desired field.
Something along the lines of 

  set string=`ruptime|tail +6|head -1|cut -d"," -f4`

 should work (head and tail to get only that line; cut to get the
fourth comma-separated field.)
 Maybe

  set string=`ruptime|sed -n6p|cut -d"," -f4`

  would work better, come to think of it.

     --- phelliax 

-- 
wiml at blake.acs.washington.edu        (206)526-5885      Seattle, Washington



More information about the Comp.unix.questions mailing list