Sponsored Content
Top Forums Shell Programming and Scripting Getting error on for loop - bash script Post 302513778 by arundhati_s on Thursday 14th of April 2011 04:42:31 AM
Old 04-14-2011
Getting error on for loop - bash script

Hi,
I am working on bash script after a long time. I am getting error near done statement while running a for loop snippet. The error says "Syntax error near unexpcted token 'done'"

please suggest what could be wrong. here is the snippet

Code:
elements=${#option_arr[@]} //an array of values
for((i=0;i<$elements;i++)); do
 if [ "${i}" -eq 0 ]; then
         BuySell="Buy"
        else if [ "${i}" -gt 0 ]; then
          if ["$BuySell" -eq "Buy" ]; then
                 BuySell="Sell"
                else
                        BuySell="Buy"
                fi
         fi
         #str="$ccyPair","$counterParty","${option_arr[${i}]}","$BuySell","$bidPrice","$askPrice","$tradeDate","$expiryDate"    
 done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

loop does not execute in bash script?

I have a very basic bash shell script, which has many "while... done; for .... done" loop clauses, like the following ~~ #!/bin/bash while blablalba; do .... done < /tmp/file for line in `cat blablabla`; do grep $line /tmp/raw ; done > /tmp/1; while blablalba2; do .... done <... (2 Replies)
Discussion started by: fedora
2 Replies

2. Shell Programming and Scripting

error in bash script 'if' loop

SEND_MESSAGE=test echo $SEND_MESSAGE if then echo `date` > update_dt_ccaps.lst echo "The file transfer failed" >> update_dt_ccaps.lst SEND_MESSAGE=false fi The above code is showing error in bash shell as : ./test: line 5: [: test: integer expression expected ... (2 Replies)
Discussion started by: DILEEP410
2 Replies

3. Shell Programming and Scripting

Bash loop script for specfic intervals

Hello, first of all I am happy to sign up here. Next is, I have shell scripts for all the files I want looped infinitely for specific intervals(This is for a wmii config). My question here is how can I run multiple scripts at a 10 second interval for instance? (4 Replies)
Discussion started by: Mesher
4 Replies

4. Shell Programming and Scripting

Whitespace in filenames in for loop in bash script

I'm trying to search all .odt files in a directory for a string in the text of the file. I've found a bash script that works, except that it can't handle whitespace in the filenames. #!/bin/bash if ; then echo "Usage: searchodt searchterm" exit 1 fi for file in $(ls *.odt); do ... (4 Replies)
Discussion started by: triplemaya
4 Replies

5. Shell Programming and Scripting

Expect script called in loop from Bash Script

Having issues with an expect script. I've been scripting bash, python, etc... for a couple years now, but just started to try and use Expect. Trying to create a script that takes in some arguments, and then for now, just runs a pwd command(for testing, final will be command I pass). Here is... (0 Replies)
Discussion started by: cbo0485
0 Replies

6. Shell Programming and Scripting

Bash script - loop question

Hi Folks, I have a loop that goes through an array and the output is funky. sample: array=( 19.239.211.30 ) for i in "${array}" do echo $i iperf -c $i -P 10 -x CSV -f b -t 50 | awk 'END{print '$i',$6}' >> $file done Output: 19.239.211.30 19.2390.2110.3 8746886 seems that when... (2 Replies)
Discussion started by: nitrohuffer2001
2 Replies

7. Shell Programming and Scripting

While loop with input in a bash script

I have the following while loop that I put in a script, demo.sh: while read rna; do aawork=$(echo "${rna}" | sed -n -e 's/\(...\)\1 /gp' | sed -f rna.sed) echo "$aawork" | sed 's/ //g' echo "$aawork" | tr ' ' '\012' | sort | sed '/^$/d' | uniq -c | sed 's/*\(*\) \(.*\)/\2: \... (3 Replies)
Discussion started by: faizlo
3 Replies

8. Shell Programming and Scripting

How to use grep in a loop using a bash script?

Dear all, Please help with the following. I have a file, let's call it data.txt, that has 3 columns and approx 700,000 lines, and looks like this: rs1234 A C rs1236 T G rs2345 G T Please use code tags as required by forum rules! I have a second file, called reference.txt,... (1 Reply)
Discussion started by: aberg
1 Replies

9. UNIX for Beginners Questions & Answers

Help with date in bash script for loop from YYYYMMDDHHMM

Hi everyone I need some help I want to create an script which does some processing it takes the two arguments 201901010000 and 201901020200 - so YYYMMDDHHMM I want to split processing into hours from start until end, I dont get why this works but when I add to a future variable... (1 Reply)
Discussion started by: kl1ngac1k
1 Replies

10. UNIX for Beginners Questions & Answers

Help with a bash loop script

Create a single bash script that does the following: a. Print out the number of occurrences for each motif that is found in the bacterial genome and output to a file called motif_count.txt b. Create a fasta file for each motif (so 3 in total) which contains all of the genes and their... (6 Replies)
Discussion started by: dre
6 Replies
Syntax::Highlight::Engine::Kate::Template(3)		User Contributed Perl Documentation	      Syntax::Highlight::Engine::Kate::Template(3)

NAME
Syntax::Highlight::Engine::Kate::Template - a template for syntax highlighting plugins DESCRIPTION
Syntax::Highlight::Engine::Kate::Template is a framework to assist authors of plugin modules. All methods to provide highlighting to the Syntax::Highlight::Engine::Kate module are there, Just no syntax definitions and callbacks. An instance of Syntax::Highlight::Engine::Kate::Template should never be created, it's meant to be sub classed only. METHODS
attributes(?$attributesref?); Sets and returns a reference to the attributes hash. basecontext(?$context?); Sets and returns the basecontext instance variable. This is the context that is used when highlighting starts. captured($cap); Puts $cap in the first element of the stack, the current context. Used when the context is dynamic. capturedGet($num); Returns the $num'th element that was captured in the current context. capturedParse($string, $mode); If $mode is specified, $string should only be one character long and numeric. capturedParse will return the Nth captured element of the current context. If $mode is not specified, all occurences of %[1-9] will be replaced by the captured element of the current context. column returns the column position in the line that is currently highlighted. contextdata(\%data); Sets and returns a reference to the contextdata hash. contextInfo($context, $item); returns the value of several context options. $item can be callback, attribute, lineending, linebeginning, fallthrough. contextParse($plugin, $context); Called by the plugins after a test succeeds. if $context has following values: #pop returns to the previous context, removes to top item in the stack. Can also be specified as #pop#pop etc. #stay does nothing. ##.... Switches to the plugin specified in .... and assumes it's basecontext. .... Swtiches to the context specified in .... deliminators(?$delim?); Sets and returns a string that is a regular expression for detecting deliminators. engine Returns a reference to the Syntax::Highlight::Engine::Kate module that created this plugin. firstnonspace($string); returns true if the current line did not contain a non-spatial character so far and the first character in $string is also a spatial character. formatTable sets and returns the instance variable format_table. See also the option format_table highlight($text); highlights $text. It does so by selecting the proper callback from the commands hash and invoke it. It will do so untill $text has been reduced to an empty string. returns a paired list of snippets of text and the attribute with which they should be highlighted. highlightText($text); highlights $text and reformats it using the format_table and substitutions includePlugin($language, $text); Includes the plugin for $language in the highlighting. includeRules($language, $text); Includes the plugin for $language in the highlighting. keywordscase Sets and returns the keywordscase instance variable. lastchar return the last character that was processed. lastcharDeliminator returns true if the last character processed was a deliminator. linesegment returns the string of text in the current line that has been processed so far, linestart returns true if processing is currently at the beginning of a line. listAdd('listname', $item1, $item2 ...); Adds a list to the 'lists' hash. lists(?\%lists?); sets and returns the instance variable 'lists'. out(?@highlightedlist?); sets and returns the instance variable 'out'. parseResult($text, $match, $lookahaed, $column, $firstnonspace, $context, $attribute); Called by every one of the test methods below. If the test matches, it will do a couple of subtests. If $column is a defined numerical value it will test if the process is at the requested column. If $firnonspace is true, it will test this also. Ig it is not a look ahead and all tests are passed, $match is then parsed and removed from $$text. pluginGet($language); Returns a reference to a plugin object for the specified language. Creating an instance if needed. reset Resets the highlight engine to a fresh state, does not change the syntx. snippet Contains the current snippet of text that will have one attribute. The moment the attribute changes it will be parsed. snippetAppend($string) appends $string to the current snippet. snippetAttribute($attribute) Sets and returns the used attribute. snippetForce Forces the current snippet to be parsed. snippetParse($text, ?$attribute?) If attribute is defined and differs from the current attribute it does a snippetForce and sets the current attribute to $attribute. Then it does a snippetAppend of $text stack sets and returns the instance variable 'stack', a reference to an array stackPull retrieves the element that is on top of the stack, decrements stacksize by 1. stackPush($tagname); puts $tagname on top of the stack, increments stacksize by 1 stackTop Retrieves the element that is on top of the stack. stateCompare(@state) Compares two lists, @state and the stack. returns true if they match. stateGet Returns a list containing the entire stack. stateSet(@list) Accepts @list as the current stack. substitutions sets and returns a reference to the substitutions hash. The methods below all return a boolean value. testAnyChar($text, $string, $insensitive, $lookahaed, $column, $firstnonspace, $context, $attribute); testDetectChar($text, $char, $insensitive, $dynamic, $lookahaed, $column, $firstnonspace, $context, $attribute); testDetect2Chars($text, $char1, $char2, $insensitive, $dynamic, $lookahaed, $column, $firstnonspace, $context, $attribute); testDetectIdentifier($text, $lookahaed, $column, $firstnonspace, $context, $attribute); testDetectSpaces($text, $lookahaed, $column, $firstnonspace, $context, $attribute); testFloat($text, $lookahaed, $column, $firstnonspace, $context, $attribute); testHlCChar($text, $lookahaed, $column, $firstnonspace, $context, $attribute); testHlCHex($text, $lookahaed, $column, $firstnonspace, $context, $attribute); testHlCOct($text, $lookahaed, $column, $firstnonspace, $context, $attribute); testHlCStringChar($text, $lookahaed, $column, $firstnonspace, $context, $attribute); testInt($text, $lookahaed, $column, $firstnonspace, $context, $attribute); testKeyword($text, $list, $insensitive, $lookahaed, $column, $firstnonspace, $context, $attribute); testLineContinue($text, $lookahaed, $column, $firstnonspace, $context, $attribute); testRangeDetect($text, $char1, $char2, $insensitive, $lookahaed, $column, $firstnonspace, $context, $attribute); testRegExpr($text, $reg, $insensitive, $dynamic, $lookahaed, $column, $firstnonspace, $context, $attribute); testStringDetect($text, $string, $insensitive, $dynamic, I$lookahaed, $column, $firstnonspace, $context, $attribute); ACKNOWLEDGEMENTS
All the people who wrote Kate and the syntax highlight xml files. AUTHOR AND COPYRIGHT
This module is written and maintained by: Hans Jeuken < haje at toneel dot demon dot nl > Copyright (c) 2006 by Hans Jeuken, all rights reserved. You may freely distribute and/or modify this module under same terms as Perl itself SEE ALSO
Synax::Highlight::Engine::Kate http:://www.kate-editor.org perl v5.16.3 2012-09-23 Syntax::Highlight::Engine::Kate::Template(3)
All times are GMT -4. The time now is 02:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy