Make ls print path
am 15.09.2007 23:51:37 von ikkjespam.salve
Sometimes I'd like to do something like:
$ less $(ls email/inbox/cur | tail -n 1)
but that fails, because ls prints only the "basename".
I can't find an option to make ls print the path!
--
Salve Håkedal
Re: Make ls print path
am 15.09.2007 23:58:42 von Janis Papanagnou
Salve Håkedal wrote:
> Sometimes I'd like to do something like:
>
> $ less $(ls email/inbox/cur | tail -n 1)
>
> but that fails, because ls prints only the "basename".
> I can't find an option to make ls print the path!
>
Use ~+ as, for example, in...
ls -d ~+/bin/*
Janis
Re: Make ls print path
am 16.09.2007 00:00:57 von cfajohnson
On 2007-09-15, Salve Håkedal wrote:
> Sometimes I'd like to do something like:
>
> $ less $(ls email/inbox/cur | tail -n 1)
>
> but that fails, because ls prints only the "basename".
> I can't find an option to make ls print the path!
less "$(ls -d email/inbox/cur/* | tail -n 1)"
Or (saves two external commands):
set -- email/inbox/cur/*
shift $(( $# - 1 ))
less "$1"
--
Chris F.A. Johnson, author
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
Re: Make ls print path
am 16.09.2007 00:22:32 von Stephane CHAZELAS
2007-09-15, 16:51(-05), Salve Håkedal:
> Sometimes I'd like to do something like:
>
> $ less $(ls email/inbox/cur | tail -n 1)
>
> but that fails, because ls prints only the "basename".
> I can't find an option to make ls print the path!
With zsh:
less email/inbox/cur/*([-1])
--
Stéphane
Re: Make ls print path
am 16.09.2007 09:57:27 von ikkjespam.salve
On 2007-09-15, Chris F.A. Johnson wrote:
> On 2007-09-15, Salve Håkedal wrote:
>> Sometimes I'd like to do something like:
>>
>> $ less $(ls email/inbox/cur | tail -n 1)
>>
>> but that fails, because ls prints only the "basename".
>> I can't find an option to make ls print the path!
>
> less "$(ls -d email/inbox/cur/* | tail -n 1)"
>
> Or (saves two external commands):
>
> set -- email/inbox/cur/*
> shift $(( $# - 1 ))
> less "$1"
>
Thank you. I had not understood that that could be used with the file
name (= "basename")! (That is not really clear form the man page, is
it?)
--
Salve Håkedal
Re: Make ls print path
am 16.09.2007 10:02:41 von ikkjespam.salve
On 2007-09-15, Janis Papanagnou wrote:
> Salve Håkedal wrote:
>> Sometimes I'd like to do something like:
>>
>> $ less $(ls email/inbox/cur | tail -n 1)
>>
>> but that fails, because ls prints only the "basename".
>> I can't find an option to make ls print the path!
>>
>
> Use ~+ as, for example, in...
>
> ls -d ~+/bin/*
>
Fine! Thank you.
--
Salve Håkedal