Home > Syntax Error > Syntax Error Near Unexpected Token Do In Shell Script

Syntax Error Near Unexpected Token Do In Shell Script

Contents

Display a Digital Clock Eating Skittles Like a Normal Person How to construct a 3D 10-sided Die (Pentagonal trapezohedron) and Spin to a face? UNIX is a registered trademark of The Open Group. Browse other questions tagged linux bash shell or ask your own question. Check for an option to use Linux/Unix style text. –lurker Jul 14 '14 at 17:36 | show 2 more comments Your Answer draft saved draft discarded Sign up or log his comment is here

You could do egrep "\"([^\"]*)?\(([^\"]*)?Linux([^\"]*)?\)([^\"]*)?\"" FILE But a less ugly way is to quote the whole expression with single quotes, and in general always strong (single) quote your regex so the done Note that repoA, repoB and repoC are being treated as variables in this context. The variable reference "${file%.extension}"$3 will try to remove ".extension" (not the variable, just the string) from the end of $file. This command made the script run correctly. –Murat Aug 24 '15 at 12:10 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using

Syntax Error Near Unexpected Token Do In Shell Script

more stack exchange 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 Try running dos2unix myscript.sh. Every if needs a then and a fi.

Code: !/bin/bash echo 9.9 `for dir in \ `logins -ox | awk -F: '($8 == "PS") { print $6 }'`; do find ${dir}/.netrc -type f \( \ -perm -g+r -o -perm done gives 5 arguments, "1", "2", etc., to "for". add a comment| 1 Answer 1 active oldest votes up vote 1 down vote accepted The Syntax error: "do" unexpected or Syntax error: "done" unexpected errors are almost certainly because you Syntax Error Near Unexpected Token Do Mac Why does Davy Jones not want his heart around him?

Why are terminal consoles still used? Syntax Error Near Unexpected Token Do For Loop Join them; it only takes a minute: Sign up Bash script syntax error “do”? second, there is a maximum line length and a maximum number of arguments a command can take in place. Is there any financial benefit to being paid bi-weekly over monthly?

done When I execute this (sh myscript.sh) I get the following: myscript.sh: line 2: syntax error near unexpected token `$'\r'' 'yscript.sh: line 2: `for repo in repoA repoB repoC; Ideas? Do Unexpected In Shell Script In the video we are using ( and not [ here is the correct line which is used in the video (while true; do echo -n "my program" >> ~/output.file; sleep Did millions of illegal immigrants vote in the 2016 USA election? Browse other questions tagged command-line bash grep regex or ask your own question.

Syntax Error Near Unexpected Token Do For Loop

current community chat Stack Overflow Meta Stack Overflow your communities Sign up or log in to customize your list. It compares all of the files in the directory to see if they are of the type of the first 2 parameters. Syntax Error Near Unexpected Token Do In Shell Script you could do, echo myscript.sh | od -c to peak at the characters. Linux Syntax Error Near Unexpected Token Do Related 2how to run a function as root in shell script1While loop help in Shell Script0Execute command on time Shell Script0Creating and executing shell scripts to run XAMPP on double click0Is

more stack exchange 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 this content Do you have any idea about why I am getting this error in this while loop? Click Here to receive this Complete Guide absolutely free. I would execute the script with the following command: ./convert.sh .avi .mp4 .flv That this, this script would convert all of the .avi and .mp4 files to .flv. Syntax Error Near Unexpected Token Do In Unix

more stack exchange 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 Difficulties interpreting this complex sentence Does enlarging a character with a reach weapon affect his threat range? Hit a curb today, taking a chunk out of the tire and some damage to the rim. http://mmonoplayer.com/syntax-error/syntax-error-near-unexpected-token-then-39-in-shell-script.html more hot questions question feed lang-sh about us tour help blog chat data legal privacy policy work here advertising info mobile contact us feedback Technology Life / Arts Culture / Recreation

Reply Commit new skills to your local repo Join 82,000+ aspiring & expert engineers who trained at Linux Academy Join Now Features For Teams Library Blog Careers Community Archive About Terms Syntax Error Near Unexpected Token Done' While Loop do is part of the syntax for for and while loops; you already have one above (where it belongs), and this one just doesn't make sense. asked 2 years ago viewed 145 times active 2 years ago Linked -1 Implementing which function in shell 8 syntax error near unexpected token ' - bash Related 3004Getting the Current/Present

Code: [[email protected] ~]# hexdump -C -n 64 heatFlux 00000000 23 21 2f 62 69 6e 2f 62 61 73 68 0a 0a 66 6f 72 |#!/bin/bash..for| 00000010 20 61 20 69

I've hit a snag in ubuntu using the latest version 13.10 Saucy. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Binary to decimal converter Square root image filter tool in Python How many times do you need to beat mom and Satan etc to 100% the game? Linux Unexpected Token Do There's error: line 6: syntax error near unexpected token `done' Why bash programing is too hard???

Join our community today! The question does not have to be directly related to Linux and any language is fair game. asked 2 years ago viewed 10452 times active 2 years ago Related 4Script doesn't work when executed with sudo3syntax error near unexpected token `('1syntax error near unexpected token `if'0syntax error near http://mmonoplayer.com/syntax-error/syntax-error-near-unexpected-token-shell-script.html Blogs Recent Entries Best Entries Best Blogs Blog List Search Blogs Home Forums HCL Reviews Tutorials Articles Register Search Search Forums Advanced Search Search Tags Search LQ Wiki Search Tutorials/Articles Search

These values have been increased with the advent of 64-bit OSes but they are still there and whatever you feed into "for" is an argument to it. If you need to reset your password, click here. Did millions of illegal immigrants vote in the 2016 USA election? Grass grows through the floor of my building Feynman diagram and uncertainty Unable to complete a task at work.

In my case, I was trying to execute the script file(written on Windows system) on linux system. Hope the file for example with vim and enable the syntax check. When I run the script, I get the error syntax error near unexpected token `do' in bash script. Unix just uses '\n'.

Is including the key as AAD actually dangerous? Word for nemesis that does not refer to a person How to construct a 3D 10-sided Die (Pentagonal trapezohedron) and Spin to a face? linux bash shell share|improve this question edited Jul 14 '14 at 16:54 asked Jul 14 '14 at 16:47 IAmYourFaja 7,33194301566 6 Check for Windows-style CR/LF in the file. Contact Us - Advertising Info - Rules - LQ Merchandise - Donations - Contributing Member - LQ Sitemap - Main Menu Linux Forum Android Forum Chrome OS Forum Search LQ

Not the answer you're looking for? for file in *.*; do #comparing the file types in the directory to the first 2 parameters passed if [ ${file: -4} == "$1" ] || [ ${file: -4 } == Idiomatic Expression that basically says "What's bad for you is good for me" Why does MIT have a /8 IPv4 block? You can do that using a variety of tools but my preference is dos2unix To install it on CentOS, Fedora or RHEL do: sudo yum install dos2unix To install dos2unix on

rmaier9 View Public Profile View LQ Blog View Review Entries View HCL Entries Find More Posts by rmaier9 08-21-2014, 06:20 AM #4 praju1 LQ Newbie Registered: Aug 2014 Posts: Log In to Answer Copyright © 2016 DigitalOcean™ Inc. Anyway, here's my quick rewrite: #!/bin/bash # $1 is the first parameter passed # $2 is the second parameter passed # $3 is the third parameter passed for file in *.*; How do I politely decline a research grant?

My advice is to avoid for-loops for things like yours altogether and use while-loops instead: instead of Code: for VAR in $(command -producing | some | list) ; do something $VAR