Inorder to accept user defined input in a shell script, make use of the read command. Try a simple example in Terminal.
Eg:
#!/usr/bin/bash
echo "Please enter your name"
read name
echo "Welcome to shell scripting $name"
Make sure the bash interpreter location is correctly defined in the shebang statement. Else you would see the error like - bad interpreter: No such file or directory
Eg:
#!/usr/bin/bash
echo "Please enter your name"
read name
echo "Welcome to shell scripting $name"
Make sure the bash interpreter location is correctly defined in the shebang statement. Else you would see the error like - bad interpreter: No such file or directory
No comments:
Post a Comment