home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / shell / 3892 < prev    next >
Encoding:
Text File  |  1992-09-10  |  1.6 KB  |  43 lines

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!usc!snorkelwacker.mit.edu!bloom-picayune.mit.edu!news.mit.edu!jdell
  3. From: jdell@golda.mit.edu (John Ellithorpe)
  4. Subject: Re: Substring of a file name
  5. In-Reply-To: urs@carp.cis.ufl.edu's message of 10 Sep 92 15:15:41 GMT
  6. Message-ID: <JDELL.92Sep10180225@golda.mit.edu>
  7. Sender: news@athena.mit.edu (News system)
  8. Nntp-Posting-Host: golda.mit.edu
  9. Organization: Massachusetts Institute of Technology
  10. References: <37016@uflorida.cis.ufl.edu>
  11. Distribution: usa
  12. Date: Thu, 10 Sep 1992 23:02:25 GMT
  13. Lines: 28
  14.  
  15. On 10 Sep 92 15:15:41 GMT, urs@carp.cis.ufl.edu (Uppili Srinivasan) said:
  16. > Nntp-Posting-Host: carp.cis.ufl.edu
  17. > Hi,
  18. > I need to write a script to read a substring of some of the filenames
  19. > in a directory. (i.e) if xy1992 is the name i need to read the last four
  20. > letters only. I guess 'awk' is ideal for this . But I am curious to
  21. > know the other ways of doing this.
  22. >
  23. > Thanx in advance
  24. > My e-mail address : urs@carp.cis.ufl.edu
  25.  
  26. Well, if you knew that the first couple of characters were always characters
  27. then you could use sed:
  28.  
  29. substring = `echo $file | sed -e 's/^[a-z][a-z]//'`
  30.  
  31. which would just delete out the first couple of characters.  Hope this
  32. helps.
  33.  
  34. John
  35. --
  36.  
  37. ===============================================================================
  38. John Ellithorpe                           | Internet: jdell@maggie.mit.edu
  39. Dept. of Physics, Rm 26-349               | Phone   : (617) 253-3074  Office
  40. Massachusetts Institute of Technology     |           (617) 253-3072  Lab
  41. Cambridge, MA  02139                      |           (617) 236-4910  Home
  42. ===============================================================================
  43.