The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 07-09-2008
c0mrade c0mrade is offline
Registered User
  
 

Join Date: May 2008
Posts: 35
shell script with input

Hi all,

Here is my shell script
Code:
#!/bin/sh
echo "What is your name"
read name
echo "What is your surname"
read surname

echo "Your name is:${name} and your surname is:${surname}"

How can I modify this script so that I input those two variables from console?Lets say my name is "first" and my surname is "last" . So when I run my script
Code:
./script.sh

and input first and last I get "Your name is:first and your surname is:last". Is it possible to modify the script so that it runs like this
Code:
./script.sh first last

and that I get same output "Your name is:first and your surname is:last" .. Thank you for your answers