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