bug-coreutils
[Top][All Lists]
Advanced

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

Re: ls: add a switch not to strip the directory we gave


From: Paul Jarc
Subject: Re: ls: add a switch not to strip the directory we gave
Date: Tue, 13 May 2003 11:43:28 -0400
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

Jim Meyering <address@hidden> wrote:
> Another way to do it, perhaps more accessible :-)
> is to use realpath (aka readlink --canonicalize), e.g.,
>
>   realpath `ls -1t ~/.procmail/bitbucket | sed q`

I don't have this command, so I can't test it, but...

>   readlink --canonicalize `ls -1t ~/.procmail/bitbucket | sed q`

This exits 1 with no output for me.  readlink sees only the basename
of a file in some directory other than the current directory, so I
don't think it can possibly construct the full path.  Even if it
could, canonicalization is not what Dan is asking for.

I think Dan's three-line script is the best way:

>> a=~/.procmail/bitbucket/
>> x=`ls -t $a|sed q`
>> f=$a/$x

Dan, if you don't want to type all that each time you want to do this,
then save the commands in a script.
#!/bin/sh -e
base=`ls -t "$1" | sed q`
echo "$1/$base"


paul




reply via email to

[Prev in Thread] Current Thread [Next in Thread]