Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to list and insert into a variable???

1 view
Skip to first unread message

Saqi

unread,
Oct 19, 2004, 6:37:24 AM10/19/04
to
Dear UNIX Lers,

This is my first time I am posting a question here and I am very
novice to UNIX.

I have a directory called jobs and one of my applications creates log
file daily in jobs directory with system job id is suffix.

I would like to insert the latest file from that directory into a
variable so that I can use that variable as part of another
application.

Any suggestions.

Your help would be much appreiciated.

Saqi

Ed Morton

unread,
Oct 19, 2004, 8:04:27 AM10/19/04
to

Saqi wrote:
> Dear UNIX Lers,
>
> This is my first time I am posting a question here and I am very
> novice to UNIX.
>
> I have a directory called jobs and one of my applications creates log
> file daily in jobs directory with system job id is suffix.
>
> I would like to insert the latest file from that directory into a
> variable so that I can use that variable as part of another
> application.
>
> Any suggestions.

If by latest you mean most recent:

var=`ls -t jobs | head -1`
echo "$var"

Ed.

Bill Marcum

unread,
Oct 19, 2004, 11:56:19 AM10/19/04
to
On 19 Oct 2004 03:37:24 -0700, Saqi
<saqi...@totalise.co.uk> wrote:
> Dear UNIX Lers,
>
> This is my first time I am posting a question here and I am very
> novice to UNIX.
>
> I have a directory called jobs and one of my applications creates log
> file daily in jobs directory with system job id is suffix.
>
> I would like to insert the latest file from that directory into a
> variable so that I can use that variable as part of another
> application.
>
var=$(ls -tr jobs/*$suffix |tail -1)


--
System Events
=-=-=-=-=-=-=
Sep 16 03:31:11 don kernel: lp0 on fire

0 new messages