LinuxQuestions.org
Register a domain and help support LQ
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 06-03-2010, 02:03 AM   #1
mech123
Member
 
Registered: Dec 2008
Posts: 36

Rep: Reputation: 16
syntax error:Not able to understand


fileListingArray2=(`cat b.txt|tr '/n' ' '`)
echo ${fileListingArray2[@]} #It gives me <1> <2> <3> <a> <4> <5> <\a> <b> <6> <7> <8> <\b> <9>
boolean=0;
for(( j=0; j<${#fileListingArray2[@]}; j++ ))
do
if [[ ${fileListingArray2[j]} =<a> ]|| [${fileListingArray2[j]}=<b>] ] # In fileListingArray2 if <a> or <b> is present then value of boolean should be 1.
then
boolean=1;
fi
done

#Got Error
#<1> <2> <3> <a> <4> <5> <\a> <b> <6> <7> <8> <\b> <9>
#./test.sh: line 6: unexpected argument `<' to conditional binary operator
#./test.sh: line 6: syntax error near `=<a'
#./test.sh: line 6: ` if [[ ${fileListingArray2[j]} =<a> ]|| [${fileListingArray2[j]}=<b>] ]
 
Old 06-03-2010, 02:14 AM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650
Try this:
Code:
fileListingArray2=(`cat b.txt|tr '/n' ' '`)
echo ${fileListingArray2[@]} #It gives me <1> <2> <3> <a> <4> <5> <\a> <b> <6> <7> <8> <\b> <9>
boolean=0;
for(( j=0; j<${#fileListingArray2[@]}; j++ ))
do
if ( [ "${fileListingArray2[j]}" = "<a>" ] || [ "${fileListingArray2[j]}" = "<b>" ] ) # In fileListingArray2 if <a> or <b> is present then value of boolean should be 1.
then
boolean=1;
fi
done

cheers
 
1 members found this post helpful.
  


Reply


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
[python] syntax Error : invalid syntax Python_user Programming 2 09-06-2009 01:52 PM
why am getting error ksh: syntax error: `fi' unexpected while running script deb4you Linux - Newbie 4 09-06-2008 09:37 AM
C++ syntax error before :: token HELP, i cant find the syntax error :( qwijibow Programming 2 12-14-2004 07:09 PM
ERROR running make when installing Nvidia drivers (syntax error) randyriver10 Linux - Software 5 02-21-2004 05:51 PM


All times are GMT -5. The time now is 04:30 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration