G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.general (More info?)

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
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.general (More info?)

See Using environment variables with Cmd.exe

Command shell Using environment variables
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds_shelloverview.mspx

Type batch files and environment variables in the Search box in Help and
Support.

--
Hope this helps. Let us know.

Wes
MS-MVP Windows Shell/User

In news:1126020010.923973.255850@g44g2000cwa.googlegroups.com,
nkhimani@gmail.com <nkhimani@gmail.com> hunted and pecked:
> 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
 

Jim

Distinguished
Mar 31, 2004
2,444
0
19,780
Archived from groups: microsoft.public.windowsxp.general (More info?)

<nkhimani@gmail.com> wrote in message
news:1126020010.923973.255850@g44g2000cwa.googlegroups.com...
> 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
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.general (More info?)

<nkhimani@gmail.com> wrote in message
news:1126020010.923973.255850@g44g2000cwa.googlegroups.com...
> 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