The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Getting yesterday DATE osymad Shell Programming and Scripting 16 06-06-2008 05:46 AM
Yesterday in i.e. May 09 and 05/09 format Daniel Gate Shell Programming and Scripting 3 05-20-2008 01:59 PM
yesterday Tlg13team Shell Programming and Scripting 0 02-27-2008 01:02 AM
How to show yesterday date wind_n_cloud Shell Programming and Scripting 1 02-16-2005 07:51 PM
minor issue on question that i had posted !! moxxx68 Post Here to Contact Site Administrators and Moderators 4 10-23-2004 01:51 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #8  
Old 12-18-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
1. Replace the [[ with the word "test" and get rid of the "]]"

2. Remove the trailing slash on the directory paths for the if/test

3. Remember UNIX file systems are case sensitive
Reply With Quote
Forum Sponsor
  #9  
Old 12-18-2007
Registered User
 

Join Date: Oct 2007
Posts: 155
Even though the trailing slash is theoretically irrelevant, it has caused me problems in the past where somehow "/a/b/c/" not equivilant to "/a/b/c".

I see no reason to replace the brackets with the "test" command. Is there a functional difference? I prefer the brackets for readability.
Reply With Quote
  #10  
Old 12-18-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by gus2000 View Post
I prefer the brackets for readability.
Personal choice, I like to see what is actually happening, ie, "if runs a program to determine which branch is executed".
Reply With Quote
  #11  
Old 12-18-2007
Smiling Dragon's Avatar
Disorganised User
 
Join Date: Nov 2007
Location: New Zealand
Posts: 734
Quote:
Originally Posted by gus2000 View Post
Even though the trailing slash is theoretically irrelevant, it has caused me problems in the past where somehow "/a/b/c/" not equivilant to "/a/b/c".
It's not irrelevant, just different. The test says "is the following entry a directory?" Putting a trailing slash says "Don't match unless this is a directory" it's redundant.

It starts to become extremely important to know the difference when you use mv, if you include a trailing / on the desitnation path, it will fail if the dir does not exist. If you leave it off, it will rename the source to the name of the desitnation directory but only if it doesn't exist :/
Reply With Quote
  #12  
Old 12-19-2007
Registered User
 

Join Date: Dec 2006
Posts: 28
Quote:
Originally Posted by Smiling Dragon View Post
It's not irrelevant, just different. The test says "is the following entry a directory?" Putting a trailing slash says "Don't match unless this is a directory" it's redundant.

It starts to become extremely important to know the difference when you use mv, if you include a trailing / on the desitnation path, it will fail if the dir does not exist. If you leave it off, it will rename the source to the name of the desitnation directory but only if it doesn't exist :/
''

I've made all the changes I get the same results.

#!/usr/bin/bash

bank=`cat /export/home/usr/banklist.txt`
cdir=`cat /export/home/usr/mountlist.txt`

for d in $cdir ;do
for i in $bank ;do

if [[ -d /apps/data/custdata/$d/$i/incoming ]] ; then
ls -ltra /apps/data/custdata/$d/$i/incoming
fi

if [[ -d /apps/data/custdata/$d/$i/outgoing ]] ; then
ls -ltra /apps/data/custdata/$d/$i/outgoing
fi
done
done;

Or

#!/usr/bin/bash

bank=`cat /export/home/usr/banklist.txt`
cdir=`cat /export/home/usr/mountlist.txt`

for d in $cdir ;do
for i in $bank ;do

if test -d /apps/data/custdata/$d/$i/incoming ; then
ls -ltra /apps/data/custdata/$d/$i/incoming
fi

if test -d /apps/data/custdata/$d/$i/outgoing ; then
ls -ltra /apps/data/custdata/$d/$i/outgoing
fi
done
done;

both get no output.

Last edited by xgringo; 12-19-2007 at 01:23 PM.
Reply With Quote
  #13  
Old 12-19-2007
Smiling Dragon's Avatar
Disorganised User
 
Join Date: Nov 2007
Location: New Zealand
Posts: 734
Quote:
Originally Posted by xgringo View Post
I've made all the changes I get the same results.
So let's take a look at the new code then...
Reply With Quote
  #14  
Old 12-19-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by Smiling Dragon View Post
So let's take a look at the new code then...
And a fully qualified subset list of expected files....
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 07:12 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