LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-08-2017, 06:57 PM   #1
barakolshe
LQ Newbie
 
Registered: Jun 2017
Posts: 7

Rep: Reputation: Disabled
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.
 
Old 07-08-2017, 08:07 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 23,817

Rep: Reputation: 6977Reputation: 6977Reputation: 6977Reputation: 6977Reputation: 6977Reputation: 6977Reputation: 6977Reputation: 6977Reputation: 6977Reputation: 6977Reputation: 6977
Quote:
Originally Posted by barakolshe View Post
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.
 
  


Reply

Tags
bash, code


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] BASH Script - What am I doing wrong in this test? - BASH Script BW-userx Programming 34 04-08-2017 01:36 PM
[SOLVED] Bash Script - Reading User Input while Processing output from Command within Bash cleeky Linux - General 5 05-27-2014 02:57 PM
[SOLVED] Converting Script from Linux (GNU) Bash 4 to Solaris Bash 2.05 - Any cheat sheet? oly_r Solaris / OpenSolaris 6 05-03-2013 08:25 AM
SSH connection from BASH script stops further BASH script commands tardis1 Linux - Newbie 3 12-06-2010 08:56 AM
[SOLVED] Using a long Bash command including single quotes and pipes in a Bash script antcore Linux - General 9 07-22-2009 11:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration