Solved

Linux Shell Scripting: Error with my .sh file

Posted on 2013-11-08
2
150 Views
Last Modified: 2013-11-08
#!/bin/sh
$x="Hello";
$y="World";
echo $x $y;

Open in new window

couchdbsite.sh: line 2: =Hello: command not found
couchdbsite.sh: line 3: =World: command not found
0
Comment
Question by:hankknight
  • 2
2 Comments
 
LVL 19

Accepted Solution

by:
simon3270 earned 500 total points
ID: 39633534
Drop the $ from the start of  lines 2 and 3.

You *set* a variable with
   name=value
the *use* the variable with
   $name
0
 
LVL 19

Expert Comment

by:simon3270
ID: 39633542
To explain, if you use a variable which has not been set, the shell replaces the variable with the empty string.  it also swallows quotes, so
    $x="Hello";
is processed to
    =Hello

Again, note that ";" is not a command *terminator* - you don't need it (and shouldn't use it) at the end of lines.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now