Bash Script Syntax Error Near Unexpected Token
Contents |
communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might
Bash Script Syntax Error Near Unexpected Token Done'
have Meta Discuss the workings and policies of this site About bash syntax error near unexpected token 1' Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads bash if else syntax error near unexpected token else' with us Ask Ubuntu Questions Tags Users Badges Unanswered Ask Question _ Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it
Bash Syntax Error Near Unexpected Token Echo'
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 top bash: syntax error near unexpected token `(' up vote 4 down vote favorite 2 I am trying to download flareget download manager via wget I get error wget
Bash Syntax Error Near Unexpected Token (' Ubuntu
http://www.flareget.com/files/flareget/debs/amd64/flareget_2.3-24_amd64(stable)_deb.tar.gz bash: syntax error near unexpected token `(' Why is that error coming and what is the solution for that? 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 should use single quotes ' or double quotes " around the URL in this case (and in general): wget 'http://www.flareget.com/files/flareget/debs/amd64/flareget_2.3-24_amd64(stable)_deb.tar.gz' From now, you should use this method in general when you use a string which contain parentheses as argument in a command. That is because parentheses are used for grouping by the shell such that they are not communicated in any way to a command. So, the bash shell will give you a syntax error: $ echo some (parentheses) bash: syntax error near unexpected token `(' $ echo 'some (parentheses)' some (parentheses) share|improve this answer edited Nov 8 '13 at 11:40 answered Nov 8 '13 at 10:30 Radu Rădeanu 77.6k24168256 add a comment| up vote 2
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow bash syntax error near unexpected token fi' the company Business Learn more about hiring developers or posting ads with us Unix &
Bash Syntax Error Near Unexpected Token Then'
Linux Questions Tags Users Badges Unanswered Ask Question _ Unix & Linux Stack Exchange is a question and answer site for users of bash syntax error near unexpected token do' Linux, FreeBSD and other Un*x-like operating systems. 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 http://askubuntu.com/questions/372926/bash-syntax-error-near-unexpected-token the top bash: syntax error near unexpected token `(' up vote 2 down vote favorite I am trying to concatenate some files side by side. I use the pr command in the terminal. It works well, but when I use it in a shell script, I get the following error message: syntax error near unexpected token `(' Here is the script: #!/bin/sh myfile1=toto1.dat myfile1=toto2.dat file_out=mytoto_out.dat touch ${file_out} /usr/bin/pr -mts' ' <( /usr/bin/cut -d' ' http://unix.stackexchange.com/questions/143753/bash-syntax-error-near-unexpected-token -s -f1,2,3,4,5,6,7,8,9,10,11 ${myfile1}) <( /usr/bin/cut -d' ' -s -f8 $myfile2) >>${file_out} echo ${file_out} " is done" shell-script share|improve this question edited Jul 12 '14 at 2:17 polym 4,52312049 asked Jul 10 '14 at 12:20 user77083 11112 Please show us the shell script that fails and not the command that works. –terdon♦ Jul 10 '14 at 12:22 It doesn't throw an error for me. What shell are you using? 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 -f8 $myfile2) >>${file_out} echo ${file_out} " is done" –user77083 Jul 10 '14 at 12:29 add a comment| 1 Answer 1 active oldest votes up vote 4 down vote On the command line, your shell is bash. In your script you're using /bin/sh. /bin/sh apparently is not bash on your system, and the <() syntax is apparently not present in whatever shell /bin/sh is. Change the shebang (the #!/bin/sh part) to #!/bin/bash. 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 draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign
of Contents Debugging a script Use a unique name for your script Read the error messages Use a good editor Write logfiles Inject debugging code Use shell debug output Simple example of http://wiki.bash-hackers.org/scripting/debuggingtips how to interpret xtrace output Making xtrace more useful Debugging commands depending on a set variable Dry-run STDIN driven commands Common error messages Unexpected end of file Unexpected end of file while looking for http://www.unix.com/shell-programming-and-scripting/129122-syntax-error-near-unexpected-token.html matching ... Too many arguments !": event not found syntax error near unexpected token `(' The CRLF issue What is the CRLF issue? How did a CR end up in my file? Why syntax error do CRs hurt? How can I find and eliminate them? 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. Use a unique name for your script Do not name your script test, for example! Why? test is the name of a UNIX®-command, and most likely built into your shell (it's syntax error near a built-in in Bash) - so you won't be able to run a script with the name test in a normal way. Don't laugh! This is a classic mistake Read the error messages Many people come into IRC and ask something like "Why does my script fail? I get an error!". And when you ask them what the error message is, they don't even know. Beautiful. Reading and interpreting error messages is 50% of your job as debugger! Error messages actually mean something. At the very least, they can give you hints as to where to start debugging. READ YOUR ERROR MESSAGES! You may ask yourself why is this mentioned as debugging tip? Well, you would be surprised how many shell users ignore the text of error messages! When I find some time, I'll paste 2 or 3 IRC log-snips here, just to show you that annoying fact. Use a good editor Your choice of editor is a matter of personal preference, but one with Bash syntax highlighting is highly recommended! Syntax highlighting helps you see (you guessed it) syntax errors, such as unclosed quotes and braces, typos, etc. From my personal experience, I can suggest vim or GNU emacs
Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here. Search Forums Show Threads Show Posts Tag Search Advanced Search Unanswered Threads Find All Thanked Posts Go to Page... unix and linux commands - unix shell scripting Syntax error near unexpected token `(' Shell Programming and Scripting Page 1 of 2 1 2 > Thread Tools Search this Thread Display Modes #1 02-03-2010 raghunsi Registered User Join Date: Nov 2008 Last Activity: 26 July 2016, 1:42 PM EDT Location: bangalore Posts: 107 Thanks: 3 Thanked 0 Times in 0 Posts Syntax error near unexpected token `(' Guys , This is an output of my script errored out for "Syntax error near unexpected token `(' " Can someone tell me whats wrong with my script. Below is my original script pasted. Code: #!/bin/bash Script Creation Date 01/21/2010 Author baraghun ##**************************************************************** ## ********** FUNCTION USAGE *********** ##**************************************************************** Script name without path BASENAME=`basename $0` Script Location LOCATION=/home/myHome The INFILE is going to use during the SSH INFILE=${HOME}/config/inFile.txt The changes will write to OUTFILE OUTFILE=${HOME}/out/outFile Functional Usage usage() { echo echo "USAGE" echo " "`basename $0`"