I'm using find to all files in directory, so I get a list of paths. However, I need only file names. i.e. I get ./dir1/dir2/file.txt and I want to get file.txt
Join Stack Overflow to learn, share knowledge, and build your career.
|
|
|
In GNU
|
|||||||||||||||||||||
|
|
If your find doesn't have a -printf option you can also use basename:
|
|||||||||||||
|
|
If you are using GNU find
Or you can use a programming language such as Ruby(1.9+)
If you fancy a bash (at least 4) solution
|
|||||
|
|
Use
You can also use
When used |
|||||||||
|
|
If you want to run some action against the filename only, using For example this:
will just echo basename But you can then
|
|||||
|
|
I've found a solution (on makandracards page), that gives just the newest file name:
(thanks goes to Arne Hartherz) I used it for
|
|||||
|