Setting a DOS variable

Forum Windows XP : Windows XP General Discussion - Setting a DOS variable

Tom's Hardware: Over 1.4 million members in 6 different countries available to answer all your high-tech questions. Sign up now! Its free!
Word :    Username :           
 

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

Sponsored Links
Register or log in to remove.

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

Reply to Jim

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

Reply to Anonymous

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 [...] rview.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

Reply to Anonymous
Tom's Hardware > Forum > Windows XP > Windows XP General Discussion > Setting a DOS variable
Go to:

There are 1125 identified and unidentified users. To see the list of identified users, Click here.

Please mind

You are about to answer a thread that has been inactive for more than 6 months.
If you still wish to proceed, please ensure that your posting is original and does not duplicate or overlap any prior responses to this thread.

Add a reply Cancel
Sponsored links
  • Ask the community now
  • Publish
Ad
They won a badge
Join us in greeting them