bitcoin
bitcoin

$107158.487773 USD

-0.13%

ethereum
ethereum

$2420.252890 USD

-0.73%

tether
tether

$1.000384 USD

0.00%

xrp
xrp

$2.179086 USD

3.40%

bnb
bnb

$645.450018 USD

0.04%

solana
solana

$143.140274 USD

1.62%

usd-coin
usd-coin

$0.999905 USD

-0.01%

tron
tron

$0.273482 USD

0.65%

dogecoin
dogecoin

$0.161823 USD

-0.39%

cardano
cardano

$0.560601 USD

0.15%

hyperliquid
hyperliquid

$36.750595 USD

0.47%

bitcoin-cash
bitcoin-cash

$501.393503 USD

1.91%

sui
sui

$2.698601 USD

2.02%

chainlink
chainlink

$13.130480 USD

0.52%

unus-sed-leo
unus-sed-leo

$9.068389 USD

0.60%

Cryptocurrency News Video

Fixing a syntax error near unexpected token in a Shell Script

May 26, 2025 at 08:51 am vlogize

Encountering a syntax error like `syntax error near unexpected token 'done'` in your shell script? Learn how to resolve this common issue in your Bash script and improve your coding skills. --- This video is based on the question https://stackoverflow.com/q/70373645/ asked by the user 'Crosheo' ( https://stackoverflow.com/u/17689388/ ) and on the answer https://stackoverflow.com/a/70373691/ provided by the user 'Raxi' ( https://stackoverflow.com/u/13830677/ ) at 'Stack Overflow' website. Thanks to these great users and Stackexchange community for their contributions. Visit these links for original content and any more details, such as alternate solutions, latest updates/developments on topic, comments, revision history etc. For example, the original title of the Question was: syntax error near unexpected token `done' | ./ABC.sh: line 14: `done' Also, Content (except music) licensed under CC BY-SA https://meta.stackexchange.com/help/licensing The original Question post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/by-sa/4.0/ ) license, and the original Answer post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/by-sa/4.0/ ) license. If anything seems off to you, please feel free to write me at vlogize [AT] gmail [DOT] com. --- Understanding and Fixing the syntax error near unexpected token 'done' in Shell Scripts If you are new to shell scripting or even if you have some experience, encountering errors can be frustrating. One common error is the syntax error near unexpected token `done', which typically indicates that there is an issue with the structure of your script. In this guide, we'll take a closer look at the problem and how to fix it effectively. The Issue The error you’re dealing with occurs when there are improper or missing syntax elements in your script. In the example you've provided, the error message clearly points to line 14 and the use of done, which is a keyword that indicates the end of a loop in Bash. However, this indicates there’s an issue in the lines that precede it – specifically, the structure of the loop and cases. Understanding the Error Message The exact error message you received indicates that Bash expected a proper syntax before it encountered the word done. This is a widespread issue among shell script writers, so you're not alone. Let’s unpack the code to locate the mistakes. Code Analysis and Fixes Let’s review the provided script: [[See Video to Reveal this Text or Code Snippet]] Identifying Errors Missing Semicolon: The condition for the while loop is missing a semicolon (;) before do. The correct syntax should be: [[See Video to Reveal this Text or Code Snippet]] Case Structure Mistake: For the case statement, the last condition in the block, [D-z], is missing closing ;;. This is how it should look: [[See Video to Reveal this Text or Code Snippet]] Revised Script After applying the fixes, your code should look like this: [[See Video to Reveal this Text or Code Snippet]] Conclusion Fixing syntax errors may seem daunting, but with practice and attention to detail, you'll find that these errors become easier to spot and correct. By making sure that your loops and case conditions are properly structured with the necessary syntax, you can avoid common pitfalls like the syntax error near unexpected token 'done'. Feel free to practice with the corrected script and experiment with additional cases. Happy scripting!
Video source:Youtube

Disclaimer:info@kdj.com

The information provided is not trading advice. kdj.com does not assume any responsibility for any investments made based on the information provided in this article. Cryptocurrencies are highly volatile and it is highly recommended that you invest with caution after thorough research!

If you believe that the content used on this website infringes your copyright, please contact us immediately (info@kdj.com) and we will delete it promptly.

Other videos published on Jun 28, 2025