-   Linux - General (
-   -   how can I take input with a shell script? (

GUIPenguin 04-11-2005 04:24 PM

how can I take input with a shell script?
I need help with taking input with a shell script

something like this

-----> take input ---> save as a var

echo $var


Zeno McDohl 04-11-2005 04:26 PM

I think it's something like this, $1 being the first arg.

if ( "$1" != "" ) set port="$1"
Where port is what you want to name the variable.

echo $port

GUIPenguin 04-11-2005 04:34 PM

I know how to save it like that.....what I am actualy looking for is to 'take input' from the user and save it in a 'var'. But Thanks

perfect_circle 04-11-2005 04:43 PM

Something like this? (in bold is my input)

skalkoto@darkstar:~/src$ ./ask_name
What's your name? John
hello John
skalkoto@darkstar:~/src$cat ask_name

echo -n "What's your name? "
read var1
echo "hello $var1"

The command you are looking for is read.

For more info, look here:

GUIPenguin 04-11-2005 04:46 PM

yes........thanks ALOT

All times are GMT -5. The time now is 08:15 AM.