Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!samsung!uakari.primate.wisc.edu!caesar.cs.montana.edu!ogicse!blake!wiml From: wiml@blake.acs.washington.edu (William Lewis) Newsgroups: comp.unix.questions Subject: Re: using sed Summary: Yet another solution Message-ID: <4956@blake.acs.washington.edu> Date: 17 Dec 89 22:54:13 GMT References: <14404@eerie.acsu.Buffalo.EDU> Reply-To: wiml@blake.acs.washington.edu (William Lewis) Organization: University of Washington, Seattle Lines: 24 In article <14404@eerie.acsu.Buffalo.EDU> kwon@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 ` 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@blake.acs.washington.edu (206)526-5885 Seattle, Washington