The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Special Forums > Windows & DOS: Issues & Discussions
Google UNIX.COM


Windows & DOS: Issues & Discussions Questions involving Unix to Windows (Desktop or Server) go here. Any Windows/DOS questions should go here as well.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
storing result of a command in variable eltinator Shell Programming and Scripting 1 04-17-2008 05:09 PM
Setting the Results of a Command to a Variable stky13 UNIX for Dummies Questions & Answers 1 02-29-2008 12:00 PM
assign subst|grep|sed command result to a variable snowbiker99 Shell Programming and Scripting 5 11-14-2007 04:08 PM
Variable for -name causing issue in Find command ParNone UNIX for Dummies Questions & Answers 2 03-24-2006 03:48 PM
find command not returning any result rraajjiibb UNIX for Advanced & Expert Users 4 07-23-2004 02:05 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 03-09-2005
Registered User
 

Join Date: Mar 2005
Posts: 1
Setting a variable to result of FIND command

I am working on a batch script where a filter is placed on a directory, and the files that come out of that filter have to be copied into another directory. More specifically, I am trying to set the results of a FIND command to a variable, so that I may access this variable / file later.
The command I have now is:
dir | find "03/07/2005 03:17 PM"|\\ramts11\MarketData\Diag\utils\cut.exe -d " " -f14
The output is in the form of a text file, like:
ccm000000493.txt
I need to store the name of this file in a variable so I can copy it to a different directory. I tried putting
SET /a CCMFile=
in front of the command, but that does not assign CCMFile to anything (the variable CCMFile is still set as null).

Any help would be greatly appreciated.
Thanks a lot,
John Favara
Reply With Quote
Forum Sponsor
  #2  
Old 03-09-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,666
These commands are ms-dos commands. Our users are not Microsoft experts. I'll move this thread to our DOS forum. But even that is really for unix-mircosoft inter-operability issues. You really should post DOS bat file questions on a Microsoft oriented site.
Reply With Quote
  #3  
Old 03-09-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,666
I decided to tackle part of this problem. My quest: write a bat file to set the environment variable x to the output of the "cd" command. I am using the newer cmd.exe on Windows XP rather than the older command.exe. Even so, this was harder than it sounds. My final bat file:
Code:
set x=hello
echo before loop %x%

for /f "usebackq" %%x in (`cd`) do (
      echo in loop x = %%x
      set x=%%x
)

echo after loop %x%
That '/f "usebackq"' option on the "for" statement is the only thing I found that can parse the output of a program. And the variable in the "for" statement seems to not be an environment variable, so I had to do that explicit "set" in the loop.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:32 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0