hankknight
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
For example:
sh ./xyz.sh Hello World
#!/bin/sh
$x="Hello";
$y="World";
echo $x $y;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
${10}
${11}
..
${255}
The only shell that doesn't support this is the tradition bourne shell.