Home > Syntax Error > Bash Arithmetic Syntax Error

Bash Arithmetic Syntax Error

Contents

The way you have it now the output of create-prompt-infobar becomes a static part of $PS1 as of your assignment to PS1. Funny how the quotes are put where they're not needed ("NONE") and not where they're needed (typical beginner mistake as that's true that it's counter-intuitive to anyone used to other kinds The backslash preceding the ! This site is not affiliated with Linus Torvalds or The Open Group in any way. http://onlinetvsoftware.net/syntax-error/bash-for-syntax-error.php

On THE other hand or on another hand? Verbs of buttons on websites On THE other hand or on another hand? This site is not affiliated with Linus Torvalds or The Open Group in any way. Browse other questions tagged bash arithmetic or ask your own question.

Bash Syntax Error Invalid Arithmetic Operator

please help, thank you! –Francis Feb 16 at 3:27 Put an echo at line 14: echo "PSPID is:$PSPID and PID is:$PID". A double quote may be quoted within double quotes by preceding it with a backslash. A name for a well-informed person who is not believed? no outgoing connection via ipv4 what is the difference between \twocolumn and \documentclass[twocolumn]{book} Unexpected parent process id in output more hot questions question feed lang-sh about us tour help blog chat

Good way to explain fundamental theorem of arithmetic? Other syntax errors preventing your script from working properly relate to argument parsing in the [ construct and the expr command. Why does bash think the file ends too soon, rather than the line? Bash Syntax Error Near Unexpected Token Else' How to make different social classes look quite different?

Instead of a while loop, why not a for loop? Did Donald Trump call Alicia Machado "Miss Piggy" and "Miss Housekeeping"? Join them; it only takes a minute: Sign up Error in bash script arithmetic syntax up vote 1 down vote favorite Script: #!/bin/bash vpct=5.3 echo $((vpct*15)) Error: ./abc.sh: line 5: 5.3: After I manipulated LINES I issued commands like 'echo', ':' and 'cd'.

Reason: removed ambiguous sentence crts View Public Profile View LQ Blog View Review Entries View HCL Entries Find More Posts by crts 08-14-2011, 04:30 PM #8 MTK358 LQ 5k Bash Syntax Error Near Unexpected Token Fi' I get an arithmetic syntax error. UNIX is a registered trademark of The Open Group. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the

Arithmetic Syntax Error In Shell Script

Unix & Linux Stack Exchange works best with JavaScript enabled current community chat Unix & Linux Unix & Linux Meta your communities Sign up or log in to customize your list. You can mitigate this by quoting your variables (e. Bash Syntax Error Invalid Arithmetic Operator When I checked NUM by itself and it worked fine... Ksh Arithmetic Syntax Error g. "$PID" rather than $PID).

With Bash and Korn shell, it is generally not needed. check over here So sayeth the Shepherd Were slings used for throwing hand grenades? Not the answer you're looking for? For details type `warranty'. 3 + 2 5 obase=2 12 1100 Remember to type cntrl-d (EOF) to exit from interactive mode. $r=3.5 $s=`echo "$r + 2.2" | bc` $echo $s Bash Syntax Error Near Unexpected Token Done'

You have *\ in an expression for arithmetic expansion, which yields the error bash: n *\ temp: syntax error: operand expected (error token is "\ temp"). However, if they can still be set to some false value. Also some shell has the [[ keyword: if [[ -e "$NAME" ]]; then share|improve this answer edited Mar 30 at 3:32 answered Mar 30 at 3:24 heemayl 18.9k13759 Thank http://onlinetvsoftware.net/syntax-error/bash-if-syntax-error.php share|improve this answer answered Apr 9 '15 at 17:50 Rahul Gohrani 12 As written, that code contains a mistake and, at least in my version of bash, doesn't actually

Please check. –Rahul Gohrani Apr 9 '15 at 17:01 I updated my post, please check ;-) –Helio Apr 9 '15 at 17:39 I shall check this. Bash Syntax Error Near Unexpected Token Then' share|improve this answer edited Apr 9 '15 at 16:12 Eliah Kagan 55.9k15162255 answered Apr 9 '15 at 16:05 Florian Diesch 46.7k12105131 add a comment| up vote 1 down vote I found Code: $ echo $COLUMNS 128 Excellent, the environment variable is set Code: $ cat col.sh #!/bin/bash echo $COLUMNS $ ./col.sh $ What the???

Your function prints the exit code of the for loop.

share|improve this answer answered Oct 31 '10 at 6:44 alex 3,16931623 getcombination() { tempres=1 a=expr \( $2 - $1 \) + 1 b=1 while [ a -le $2 -a Of course, this would mean that you also must have forgotten a space in the same line. linux shell-script scripting share|improve this question edited Feb 16 at 5:08 asked Feb 15 at 8:23 Francis 32 1 Could be that any of $PSPID or $PID is empty at Bash Syntax Error Near Unexpected Token Do' The values got set correctly after issuing 'ls'.

You should use bc to perform such calculations, just as in dogbane's solution, except that you should escape the expression using quotes so the * character doesn't cause unwanted shell expansion. Depending on what is legal for your situation, you could simply add a loop handling each pid separately (for pid in $PID...). Main Menu LQ Calendar LQ Rules LQ Sitemap Site FAQ View New Posts View Latest Posts Zero Reply Threads LQ Wiki Most Wanted Jeremy's Blog Report LQ Bug Syndicate Latest weblink share|improve this answer answered Feb 15 at 10:04 meuh 15.5k1729 Hi meuh, should I double quote all the $PID in my script or just the $PID from this line:

How to pluralize "State of the Union" without an additional noun? You should also mention the shell you're using (usually bash). What are the holes on the sides of a computer case frame for?