Results 1 to 4 of 4
Hi,
I have a certain number, let's say $n, of input files *.inp for a software i use.
For each of them I'll get an output file, *.out. These output ...
- 02-08-2010 #1Just Joined!
- Join Date
- Feb 2010
- Posts
- 8
compare two env variables
Hi,
I have a certain number, let's say $n, of input files *.inp for a software i use.
For each of them I'll get an output file, *.out. These output files are, all together, an input for a second software I use.
For this reasons, I collect all the output files in a folder, let's say pop_folder.
Before I run the second software I have to make sure that the first one runs successfully and all .out files joined the pop_folder.
i'm trying something like that:
cd pop_folder
while something=true;
do
sleep 10
m=$(ls -l *.out | wc -l)
echo $m
echo $n
if test ["$n"="$m"]
then
echo "entering if...."
make job
something=false
fi
done
in my display I get:
0
3
entering if..
it seems that my if condition is true despite the actual values of $n and $m.
What's wrong??
thanks in advance for any suggestion.
- 02-08-2010 #2Linux User
- Join Date
- Nov 2009
- Location
- France
- Posts
- 292
This is an assignment and will always be true =>Code:something=true
Code:while "$something"="true" #and later on something="false"
You are making 2 tests =>Code:if test ["$n"="$m"]
Code:#Either if [ "$n" = "$m" ] #or if test "$n" = "$m" #note the white spaces
0 + 1 = 1 != 2 <> 3 != 4 ...
Until the camel can pass though the eye of the needle.
- 02-09-2010 #3Just Joined!
- Join Date
- Feb 2010
- Posts
- 8
it works! Thanks a lot!
by the way.. why does the blank space make the difference?
- 02-09-2010 #4Linux User
- Join Date
- Nov 2009
- Location
- France
- Posts
- 292
The '[' is a command, /usr/bin/[ and works as /usr/bin/test
Everything that follow are arguments, which must therefore be separated by white spaces. The last argument must be ']'.0 + 1 = 1 != 2 <> 3 != 4 ...
Until the camel can pass though the eye of the needle.


Reply With Quote
