Setting a DOS variable

N

nkhimani

Folks,

I need help ... in UNIX world it is relatively easy to set a variable
from a process. For example:
$ junk=`ls -altr | tail -1 | awk '{print $9}'`
$ echo ${junk}

This sets variable 'junk' to the file name of most recent file.

What's the trick to perform this in DOS world? TIA,

-NK
 
J

Jim

Folks,

I need help ... in UNIX world it is relatively easy to set a variable
from a process. For example:
$ junk=`ls -altr | tail -1 | awk '{print $9}'`
$ echo ${junk}

This sets variable 'junk' to the file name of most recent file.

What's the trick to perform this in DOS world? TIA,

-NK
XP has no DOS. It has, instead, the CMD shell which resembles DOS.
XP calls similar things environment variables. One sets an environment
variable via the set command in the cmd shell. It would be best to look in
Help & Support before proceeding further.
Jim
 
B

billious

Folks,

I need help ... in UNIX world it is relatively easy to set a variable
from a process. For example:
$ junk=`ls -altr | tail -1 | awk '{print $9}'`
$ echo ${junk}

This sets variable 'junk' to the file name of most recent file.

What's the trick to perform this in DOS world? TIA,

-NK

within a batch file:

for /f %%i in ('dir /b/o:d/a:-d c:\dirname\filemask') do set junk=%%i

/a:-d suppresses directory names
/o:d sorts in order of date. For the earliest, use /o:-d

HTH

....Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top