in reply to greping from lists

It seems clear that Fletch has the right answer for you, but if you happen to be one of those people who likes to use existing shell utilities do your work for you, you could try it like this:
$destination = (split /\n/, `ls -dt /path/to/targets/PC*`)[0]; chdir $destination;
The options given to "ls" are: "d": list just the names of directories, not their contents; "t": order the listing newest-to-oldest. (You were using "r" with "t" which meant list the entries oldest-to-newest, and you weren't limiting the command to just entries starting with "PC".) Note that you don't need to include the "l" option (long, detailed format) to make "ls" order its output by date.

Replies are listed 'Best First'.
Re: Re: greping from lists
by suekawar (Novice) on Feb 17, 2003 at 22:46 UTC
    thanks all for the help