LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Help in a bash script (https://www.linuxquestions.org/questions/linux-newbie-8/help-in-a-bash-script-4175609478/)

barakolshe 07-08-2017 06:57 PM

Help in a bash script
 
Hello, I am pretty new to bash scripts, I have written this simple script:
#!/bin/bash

flag = 0
for i in {1..9999}
do
if [ "$flag" -ne 1 ];
then
echo "im here"
fi;
done

But the script gives me an error which I don't understand,
the script just writes 9999 rows of this:
./dump.sh: line 6: [: -ne: unary operator expected

Thanks in advance for the help.

TB0ne 07-08-2017 08:07 PM

Quote:

Originally Posted by barakolshe (Post 5732606)
Hello, I am pretty new to bash scripts, I have written this simple script:
#!/bin/bash

flag = 0
for i in {1..9999}
do
if [ "$flag" -ne 1 ];
then
echo "im here"
fi;
done

But the script gives me an error which I don't understand,
the script just writes 9999 rows of this:
./dump.sh: line 6: [: -ne: unary operator expected

Thanks in advance for the help.

Again, as with your other post about scripting, you need to put your scripts into CODE tags, and you need to read the bash scripting tutorials you've been pointed to. Again, your error is VERY clear...it's telling you what line the error is on, and the fact that you're trying to perform an operation on something that wasn't defined. Same cause as your other post, same solution as your other post.


All times are GMT -5. The time now is 08:24 PM.