Bash Shell Script Syntax Error Near Unexpected Token
Contents |
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
Linux Syntax Error Near Unexpected Token Then'
site About Us Learn more about Stack Overflow the company Business Learn more linux syntax error near unexpected token newline' about hiring developers or posting ads with us Unix & Linux Questions Tags Users Badges Unanswered Ask Question _ syntax error near unexpected token (' in linux Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute: Sign up Here's how it
Bash Syntax Error Near Unexpected Token R
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 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
Syntax Error Near Unexpected Token Bash Function
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' ' -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
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 syntax error near unexpected token mac site About Us Learn more about Stack Overflow the company Business Learn more
Bash Syntax Error Near Unexpected Token (' Ubuntu
about hiring developers or posting ads with us Unix & Linux Questions Tags Users Badges Unanswered Ask Question _ Unix syntax error near unexpected token in case statement & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute: Sign up Here's how it http://unix.stackexchange.com/questions/143753/bash-syntax-error-near-unexpected-token works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Shell script - syntax error near unexpected token `[' up vote 0 down vote favorite When I open my terminal I get the following error: bash: /home/ai/.bashrc: line 75: syntax error near unexpected token `[' bash: /home/ai/.bashrc: line 75: `if [ -x /usr/bin/dircolors ]; then' The http://unix.stackexchange.com/questions/92000/shell-script-syntax-error-near-unexpected-token relevant part of the bashrc file script starting with the comment is as follows: # enable color support of ls and also add handy aliases if [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" alias ls='ls --color=auto' #alias dir='dir --color=auto' #alias vdir='vdir --color=auto' alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto' fi What am I doing wrong and how to correct this? bash shell share|improve this question edited Sep 23 '13 at 20:51 Gilles 369k666681119 asked Sep 23 '13 at 12:26 user2561310 112 6 Can you post the whole file to pastebin or something? I suspect that the error is before line 75. –phunehehe Sep 23 '13 at 12:32 @ phunehehe, Hi! I pasted the whole thing at pastebin.com under the name: whole bashrc file-amai14 (Here [link] (pastebin.com/2scppXxi) Please have a look! –user2561310 Sep 23 '13 at 13:50 add a comment| 2 Answers 2 active oldest votes up vote 3 down vote Looking at your pastebin link, you're missing an esac to end the case statement right before the problematic block. share|improve this answer edited Sep 23 '13 at 14:11 answered Sep 23
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 the company Business Learn more about hiring http://stackoverflow.com/questions/20895946/syntax-error-near-unexpected-token-bash developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; http://www.unix.com/shell-programming-and-scripting/129122-syntax-error-near-unexpected-token.html it only takes a minute: Sign up syntax error near unexpected token ' - bash up vote 8 down vote favorite 1 I have a written a sample script on my Mac #!/bin/bash test() { echo "Example" } test exit syntax error 0 and this works fine by displaying Example When I run this script on a RedHat machine, it says syntax error near unexpected token ' I checked that bash is available using cat /etc/shells which bash shows /bin/bash Did anyone come across the same issue ? Thanks in advance ! linux bash shell scripting share|improve this question edited Dec 7 '15 at 20:12 Tomasz Jakub Rup 4,98471335 asked Jan 3 '14 at 3:20 user3155779 43113 still the syntax error near same . . –user3155779 Jan 3 '14 at 3:23 hmm I don't know. I can execute this correctly on a Fedora machine. –Michael Berkowski Jan 3 '14 at 3:25 1 Can you recreate the entire file? Perhaps you have a non-printable in there causing the fault. –Michael Berkowski Jan 3 '14 at 3:28 4 @user3155779 Could you close the question, since the actual problem didn't relate to anything asked here (that is, wasn't found in the code as-given byte-for-byte)? –Charles Duffy Jan 3 '14 at 4:47 3 This question appears to be off-topic because the solution was unrelated to the question as asked. –chepner Jan 3 '14 at 16:23 | show 4 more comments 4 Answers 4 active oldest votes up vote 17 down vote accepted It could be a file encoding issue. I have encountered file type encoding issues when working on files between different operating systems and editors - in my case particularly between Linux and Windows systems. I suggest checking your file's encoding to make sure it is suitable for the target linux environment. I guess an encoding issue is less likely given you are using a MAC than if you had used a Windows text editor, however I think file encoding is still worth considering. --- EDIT (Add an actual solution as recommended by @Potatoswatter) To demonstrate how file type encoding could be this issue, I copy/pasted your
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`"