The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 10-10-2008
gugs gugs is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 44
Listing a directory via a script using variables

In my script I need to list the directory, where the generic name of the files will change, in my test case its set to TEST_*.mqsc. I wrote a small test script as below, but it just does not pip the listing to a file.
Any idea why?

dir='C:/cygwin/var/log/img/aut/'
file=TEST01_*.mqsc
ls $dir | grep "$file" > test.txt


When I run it in debug I get the following:

$ bash -x test.sh
+ dir=C:/cygwin/var/log/img/aut/
+ file='TEST01_*.mqsc'
+ ls C:/cygwin/var/log/img/aut/
+ grep TEST01_080924.mqsc TEST01_080925.mqsc TEST01_080926.mqsc TEST01_080927.mq
sc TEST01_080928.mqsc TEST01_080929.mqsc TEST01_080930.mqsc TEST01_081001.mqsc T
EST01_081002.mqsc TEST01_081003.mqsc TEST01_081004.mqsc TEST01_081005.mqsc TEST0
1_081006.mqsc TEST01_081007.mqsc TEST01_081008.mqsc TEST01_081009.mqsc TEST01_08
1010.mqsc
+ rc=1
+ echo 'Return Code is: 1'
Return Code is: 1