Re: truncate until delimiter
On Sun, Feb 28, 2010 at 03:13:36PM +0100, Vadkan Jozsef wrote:
> e.g.:
>
> $ ls -tr `find -type f` | grep ".txt$" | rev
> txt.nimdaymphp/.
> txt.ccuc/aborp/.
> txt.og/.
> txt.osle/.
> txt.kidosam/.
Why ls?
find -type f | grep ".txt$" | rev
(Others already noted that you can probably get what you wanted from
find directly. But let's answer your question directly)
>
>
> I Want to truncate this output, until the first "/":
>
> $ ls -tr `find -type f` | grep ".txt$" | rev | THE-MAGIC-COMES-HERE
> .
> aborp/.
> .
> .
> .
Surely you can do that with sed, but as you already mentioned rev, you
can use:
rev | cut | rev
So basically:
find -type f | grep ".txt$" | rev | cut -d/ -f1
Maybe add an extra rev in the end to have proper names.
>
> How?
>
> I just want to modify the names of some files, but I can't do it if they
> have their full path "in their names"..
--
Tzafrir Cohen | tzafrir@jabber.org | VIM is
http://tzafrir.org.il | | a Mutt's
tzafrir@cohens.org.il | | best
ICQ# 16849754 | | friend
Reply to: