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

Re: truncate until delimiter



Vadkan Jozsef wrote:
e.g.:

$ ls -tr `find -type f` | grep ".txt$" | rev
txt.nimdaymphp/.
txt.ccuc/aborp/.
txt.og/.
txt.osle/.
txt.kidosam/.


I Want to truncate this output, until the first "/":

$ ls -tr `find -type f` | grep ".txt$" | rev | THE-MAGIC-COMES-HERE
You could use "cut -d/ -f1".
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"..

In this case there is an easier command called "basename".

But there are some better possibilities. "find" knows options like
"-name" (replaces your grep) and "-printf" (replaces your ls -tr, rev
and the magic one)

Thank you!
Regards.


Reply to: