Andrew Libby on 16 Nov 2009 17:48:51 -0800


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] extended 'cut' functionality?


Cheap, I know, but how about:

awk '{printsubstr($0,length($0)-3,length($0))}'

Andy



Randall A Sindlinger wrote:
> Hi folks,
> 
> Quick (stupid) question.
> 
> The 'cut' utility will let me do trivial string manipulation counting
> from the beginning of a string.
> 
> Is there anything that provides similar, but extended, functionality to
> count from the _end_ of a string?
> 
> Specifically, I'd like to be able to 
>   cd `perldoc -l Some::module | cut-from-end 3`
> 
> Sure, I know there are other things I could do, like doing
>   cut -d . -f 1
> or an awk thing, but both of those just don't feel "right".  It should
> be trivial to snip off the end of a string from the command line.
> 
> I'd google it, but I can't imagine the crud I'd have to wade through.
> 
> -Randall
> 
> ___________________________________________________________________________
> Philadelphia Linux Users Group         --        http://www.phillylinux.org
> Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
> General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug

-- 

===============================================
xforty technologies
Andrew Libby
alibby@xforty.com
http://xforty.com
610-761-1991
===============================================

___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug