On Fri, 2003-06-20 at 14:05, Tony Vance wrote: > Hey everyone, > > I'm writing a shell and would like to cut some input from right to left, rather than > left to right. How do I do that? > > For example I want to cut of the last 4 characters of: > > typical_rpm_example.rpm > > So the result will not show the extension: > > typical_rpm_example
I love sed, so the first thing I tought of was echo "typ.ical.rpm" | sed 's/\.[^\.]*$//' Which you could do to reassign a variable like so FILE=$(echo $FILE | sed 's/\.[^\.]*$//' Note that this is a more general purpose solution. It stips any extension. If you know you always want the last four characters you can just: FILE=$(echo $FILE | sed 's/....$//' Regular expressions are such useful things. KSH has some built in RE functions, that I think make it possible to do all this without forking. Bash might also. -- Stuart Jansen <[EMAIL PROTECTED], AIM:StuartMJansen> "What hole did you dig that up from?" -- my roommate commenting on my taste in music
signature.asc
Description: This is a digitally signed message part
_______________________________________________ newbies mailing list [EMAIL PROTECTED] http://phantom.byu.edu/cgi-bin/mailman/listinfo/newbies
