Link to home
Start Free TrialLog in
Avatar of hankknight
hankknightFlag for Canada

asked on

Linux Shell Scripting: Passing String Values

How can I pass the value of x and y through the command path?

For example:

sh ./xyz.sh Hello World
#!/bin/sh
$x="Hello";
$y="World";
echo $x $y;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of simon3270
simon3270
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Note that you can only have 9 parameters passed like this ($1 to $9).  If you try to refer to $10 in your script, it will use the value of $1 and append a zero to that value.
Avatar of Tintin
Tintin

To refer to parameters 10-255, you need to enclose them in braces, eg:

${10}
${11}
..
${255}

The only shell that doesn't support this is the tradition bourne shell.