Home > Syntax Error > Bash Script Syntax Error Near Unexpected Token

Bash Script Syntax Error Near Unexpected Token


the new script is: #!/bin/bash color_def="~/.colorrc" if [[ -f $color_def ]]; then . $color_def else # color definitions black="$(tput setaf 0)" darkgrey="$(tput bold ; tput setaf 0)" lightgrey="$(tput setaf Use a unique name for your script Do not name your script test, for example! the script can't be executed The error message can vary. Find all posts by hergp

#7 02-03-2010 raghunsi Registered User Join Date: Nov 2008 Last Activity: 26 July 2016, 1:42 PM EDT Location: bangalore Posts: 107 Thanks: http://sovidi.com/syntax-error/bash-script-syntax-error-near-unexpected-token-do.php

Hint: These modes can be entered when calling Bash: from commandline: bash -vx ./myscript from shebang (OS dependant): #!/bin/bash -vx Simple example of how to interpret xtrace output Here's a simple Is the standard Canon 18-55 lens the same as 5 years ago? How to map and sum a list fast? Can I use an HSA as investment vehicle by overcontributing temporarily?

Bash Script Syntax Error Near Unexpected Token Done'

Is it possible to check for existence of member template just by identifier? What is the sh -c command? Having a problem logging in? You are currently viewing LQ as a guest.

Please visit this page to clear all LQ-related cookies. See the example for xtrace output from above. See also Discussion Debugging a script These few lines are not intended as a full-fledged debugging tutorial, but as hints and comments about debugging a Bash script. Bash Syntax Error Near Unexpected Token (' Ubuntu share|improve this answer answered Oct 1 '11 at 18:23 Daniel Beck♦ 79.6k9188251 add a comment| up vote 1 down vote Check the end line character in the file.

Note that registered members see fewer ads, and ContentLink is completely disabled once you log in. Use it like this: script_debug=1 # to turn it off, set script_debug=0 debugme logger "Sorting the database" database_sort debugme logger "Finished sorting the database, exit code $?" Of course this can pid=$(< fooservice.pid) echo "DEBUG: read from file: pid=\"$pid\"" >&2 Bash's printf command has the %q format, which is handy for verifying whether strings are what they appear to be. At the very least, they can give you hints as to where to start debugging.

Too many arguments !": event not found syntax error near unexpected token `(' The CRLF issue What is the CRLF issue? Bash Syntax Error Near Unexpected Token Fi' f1 # Still an error message. # However... 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 echo $SHELL –LatinSuD Jul 10 '14 at 12:23 #!/bin/sh myfile1=toto1.dat myfile1=toto2.dat file_out=mytoto_out.dat touch ${file_out} /usr/bin/pr -mts' ' <( /usr/bin/cut -d' ' -s -f1,2,3,4,5,6,7,8,9,10,11 ${myfile1}) <( /usr/bin/cut -d' ' -s

Bash Syntax Error Near Unexpected Token 1'

zirias View Public Profile View LQ Blog View Review Entries View HCL Entries Find More Posts by zirias 07-10-2010, 01:37 AM #5 grail LQ Guru Registered: Sep 2009 Location: Adopt A Jet/Book So sayeth the Shepherd How rich can one single time travelling person actually become? Bash Script Syntax Error Near Unexpected Token Done' I already did this for you, but please remember it for the future. –slhck Oct 1 '11 at 18:31 | show 2 more comments 2 Answers 2 active oldest votes up Bash If Else Syntax Error Near Unexpected Token Else' gr8 ..

Are there any 'smart' ejection seats? his comment is here Problem with using pause and onslide in one frame Integral using residue theorem complex analysis What could cause the throttle to stick in my Ford Ranger? It sounds like the shell was complaining about the ^M carriage return character, not the quote as the OP seemed to indicate. –Potatoswatter Jan 5 '14 at 4:41 | show 1 But I am always getting an error and can't figure out on how to fix it. #!/bin/bash export VCF_FILE='KI_subsetted.recode.vcf' for i in $(seq 22) do; /home/lab/Desktop/vcftools_0.1.13/bin/vcftools --vcf $VCF_FILE --chr i --out Bash Syntax Error Near Unexpected Token Echo'

it worked .. Common error messages Unexpected end of file script.sh: line 100: syntax error: unexpected end of file Usually indicates exactly what it says: An unexpected end of file. Reason: Fixed code tags Remove advertisements Sponsored Links raghunsi View Public Profile Find all posts by raghunsi #2 02-03-2010 hergp Problem Eliminator Join this contact form I have a suggestion for putting in DEBUG switches.

A simple visual puzzle to die for Limit involving exponentials and arctangent without L'Hôpital Is 8:00 AM an unreasonable time to meet with my graduate students and post-doc? Bash Syntax Error Near Unexpected Token Then' what needs to be changed or manipulated in the above script Last edited by Scott; 02-03-2010 at 02:30 AM.. Code: NEWFILE=$OUTFILE$(date +%y%m%d-%H%M%S).${DPDEVICE} mv -if $OUTFILE $NEWFILE ...

Why does Windows show "This device can perform faster" notification if I connect it clumsily?

MSDOS uses: \r\n (ASCII CR #13 ^M, ASCII LF #10) UNIX® uses: \n (ASCII LF #10) Keep in mind your script is a plain text file, and the CR character means f2 # Now, it's all right to call "f2", #+ since its definition has been made visible by calling "f1". # Thanks, S.C.

Function declarations Debugging commands depending on a set variable For general debugging purposes you can also define a function and a variable to use: debugme() { [[ $script_debug = 1 ]] && "[email protected]" Bash Syntax Error Near Unexpected Token Do' Why not? # Now, let's invoke the function. _ # __________ # ^^^^^^^^^^ 10 underscores (10 x function name)! # A "naked" underscore is an acceptable function name. # In fact,

Probably you have Windows style (CR + LF) and you should have Unix/Linux style (only LF). declare -f f1 # This doesn't help either. Should indoor ripened tomatoes be used for sauce? http://sovidi.com/syntax-error/bash-for-syntax-error-near-unexpected-token.php The reason is unknown, but it seems to be deliberate.

asked 2 years ago viewed 46333 times active 2 years ago Related 0why syntax error near unexpected token ' fi '0Bash script throws “syntax error near unexpected token `}'” when run0Why When taking passengers, what should I do to prepare them? The error is printed like this: ./ex6.sh: line2: $'\r': command not found ./ex6.sh: line3: syntax error near unexpected token '$'\r'' ./ex6.sh: line3: 'fund () The file is called ex6.sh. Alias expansion happens before the real language interpretion, thus the alias is expanded and makes your function definition invalid.

I get an error!". EOF cat «EOF default colors are: ${lc}- shell level color: cyan ${sc}- script name: yellow ${lnc}- line number: red ${fc}- function name: green ${cc}- command executed: white EOF } debug_cmd() { This is unlikely to help. –Cfreak Sep 17 '14 at 15:41 the dos2unix package includes the tool "mac2unix" –Max Mar 16 '15 at 10:20 add a comment| up vote Find all posts by hergp #5 02-03-2010 raghunsi Registered User Join Date: Nov 2008 Last Activity: 26 July 2016, 1:42 PM EDT Location: bangalore Posts: 107

Browse other questions tagged linux bash bash-scripting . asked 2 months ago viewed 92 times active 2 months ago Related 14Why did ; after & return an unexpected token error in bash?1“Syntax error near unexpected token '$'\r''” in shell share|improve this answer answered Jul 10 '14 at 12:38 Patrick 34.1k680129 Thanks that is it –user77083 Jul 10 '14 at 12:43 add a comment| Your Answer draft saved bash scripts wget share|improve this question asked Nov 8 '13 at 10:27 Registered User 1,15472237 add a comment| 2 Answers 2 active oldest votes up vote 6 down vote accepted You

These unmatched errors occur with: double-quote pairs single-quote pairs (also $'string'!) missing a closing } with parameter expansion syntax Too many arguments bash: test: too many arguments You most likely forgot Religious supervisor wants to thank god in the acknowledgements How would family relationships change if legal system uses collective punishment? Why did companions have such high social standing? did you close your ( with a )?

The debug.sh script is (feel free to copy, use and evolve it as you see fit): #!/bin/bash PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' export PS4 usage() { cat <<'EOF' usage: debug Please delete my previous version and post this one instead.