home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / unix / question / 14683 < prev    next >
Encoding:
Internet Message Format  |  1992-12-14  |  1.3 KB

  1. Path: sparky!uunet!utcsri!torn!nott!bnrgate!bcars664!leibniz!walt
  2. From: walt@bcarh1d7.bnr.ca (Walt Sullivan)
  3. Newsgroups: comp.unix.questions
  4. Subject: Re: Command to parse text...
  5. Message-ID: <WALT.92Dec14133826@bcarh1d7.bnr.ca>
  6. Date: 14 Dec 92 18:38:26 GMT
  7. References: <lux.723676699@sol.UVic.CA> <1992Dec6.230758.5330@news.columbia.edu>
  8. Sender: news@bcars664.bnr.ca
  9. Organization: Bell-Northern Research, Ottawa, Canada
  10. Lines: 34
  11. In-reply-to: kwak@cunixf.cc.columbia.edu's message of 6 Dec 92 23:07:58 GMT
  12.  
  13. >>>>> On 6 Dec 92 23:07:58 GMT, kwak@cunixf.cc.columbia.edu (Nancy Kwak) said:
  14. Nancy> Nntp-Posting-Host: cunixf.cc.columbia.edu
  15.  
  16. Nancy> In article <lux.723676699@sol.UVic.CA> lux@sol.UVic.CA (Michael O'Henly) writes:
  17. >    I need a command that will take a line of input that looks like
  18. >this...
  19. >
  20. >        /is/gd/.int_res/.text/.lib/.docs/filename
  21. >
  22. >    ...and return the string "filename". In other words, it's got to
  23. >return all the text between the last "/" and the end of the input
  24. >line.
  25.  
  26. Nancy>     this should do it.
  27.  
  28. Nancy>     for $a = "/usr/abc/file" or just "file"
  29.  
  30. Nancy>     expr $a : '.*/\(.*\)' \| $a
  31.  
  32. what's wrong with basename(1)?
  33.  
  34. a="/is/gd/.int_res/.text/.lib/.docs/filename"
  35. echo "`basename $a`"
  36.  
  37. produces
  38.  
  39. filename"
  40.  
  41.  
  42. --
  43. Walt Sullivan
  44. INTERNET: walt@bnr.ca (work)
  45. UUCP: walt@orbit.ocunix.on.ca (home)
  46. FIDO: 1:163/109.4
  47.