James Barrett on 16 Nov 2009 18:47:02 -0800


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

Re: [PLUG] extended 'cut' functionality?


Not an answer to your original question, but the 'dirname' utility
will achieve what you are seeking.

$ dirname /usr/share/doc/mysql-server-5.0/examples/my-small.cnf
/usr/share/doc/mysql-server-5.0/examples

This utility does not seem to read from standard input, so YMMV. You
may be able to nest backticked statements, but that just seems so
wrong...

--
Jim

On Mon, Nov 9, 2009 at 2:16 PM, Randall A Sindlinger
<rsindlin+plug@seas.upenn.edu> 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
>
___________________________________________________________________________
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