Posted a Question Yesterday


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Posted a Question Yesterday
# 8  
Old 12-18-2007
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
# 9  
Old 12-18-2007
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.
# 10  
Old 12-18-2007
Quote:
Originally Posted by gus2000
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".
# 11  
Old 12-18-2007
Quote:
Originally Posted by gus2000
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 :/
# 12  
Old 12-19-2007
Quote:
Originally Posted by Smiling Dragon
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 04:23 PM..
# 13  
Old 12-19-2007
Quote:
Originally Posted by xgringo
I've made all the changes I get the same results.
So let's take a look at the new code then...
# 14  
Old 12-19-2007
Quote:
Originally Posted by Smiling Dragon
So let's take a look at the new code then...
And a fully qualified subset list of expected files....
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Solaris

This must be the dumbest question ever posted -T5140 power button

I have a T5140 and cannot find the power switch -is there an on/off button? Good grief ! Thank you in advance. joe (3 Replies)
Discussion started by: joboy
3 Replies

2. Post Here to Contact Site Administrators and Moderators

Spam being posted by user

The second post in this thread is spam. All of the other posts that I looked at by the same user are also spam. https://www.unix.com/shell-programming-scripting/152728-using-grep-returns-partial-matches-i-need-get-exact-match-nothing.html Don't know if the individual reply can be scratched,... (2 Replies)
Discussion started by: agama
2 Replies

3. Forum Support Area for Unregistered Users & Account Problems

Posted thread

Hi, I joined yesterday and posted a thread and received emails from people suggesting solutions. My problem is that when I tried to access my posting this morning by clicking on the link in an emial, it said I wasn't registered and I had to re-register and I can't find my posting. The emial I... (1 Reply)
Discussion started by: hdixon
1 Replies

4. What is on Your Mind?

How many has posted over 1000 posts????

Hey all, does any one know how many out of 49000 odd members have crossed the postings over 1000 messages???? (6 Replies)
Discussion started by: ahmedwaseem2000
6 Replies

5. Post Here to Contact Site Administrators and Moderators

posted twice on same thread..

sorry! accidentally posted the same post twice on a thread.. could you please remove the second .. thanx moxxx68 (1 Reply)
Discussion started by: moxxx68
1 Replies

6. Post Here to Contact Site Administrators and Moderators

how to delete a posted thread?

if any user think that the thread posted by them is not good and want to delete it how to do that? (1 Reply)
Discussion started by: sekar sundaram
1 Replies

7. Post Here to Contact Site Administrators and Moderators

minor issue on question that i had posted !!

to the moderators of this site... i posted a question several weeks ago about a egep -e if you look through my posts you will see that my question was fully plausible as a reasonable post that could have been answered even it was to say that I should search the man pages myself and find the... (4 Replies)
Discussion started by: moxxx68
4 Replies
Login or Register to Ask a Question