Programming With Linux Shell Tutorial By Example Passing Arguments To A Script
Posted On Thu May 03, 2007 By linux In Linux Shell Programming Forums And Topics Discussions Forums
in addition to the nuilt-in variables, the shell is programmed to interpret special variables names. just follow these steps and it will show you how you can start making simple shell script on this short tutorial to show you how you can program in linux shell
step 1. create a file called my_script
step 2. add the following lines and save the file
* to save the file just hit CNTL + X and say yes at the prompt to save the file
step 3. make the file executable
step 4. run the script and declare the variables
step 5. the output should look similar to something like this
step 1. create a file called my_script
nano my_script
step 2. add the following lines and save the file
echo hello $USER
echo 'The contents of variable $1 is ' $1
echo 'The contents of variable $2 is ' $2
echo 'The contents of variable $3 is ' $3
echo 'The contents of variable $0 is ' $0
echo 'The contents of variable $* is ' $*
echo 'The contents of variable $# is ' $#
echo 'The contents of variable $$ is ' $$
echo 'The contents of variable $1 is ' $1
echo 'The contents of variable $2 is ' $2
echo 'The contents of variable $3 is ' $3
echo 'The contents of variable $0 is ' $0
echo 'The contents of variable $* is ' $*
echo 'The contents of variable $# is ' $#
echo 'The contents of variable $$ is ' $$
* to save the file just hit CNTL + X and say yes at the prompt to save the file
step 3. make the file executable
chmod 755 my_script
step 4. run the script and declare the variables
./my_script Wallpaperama Wallpapers Learn Linux Tutorial Hosting
step 5. the output should look similar to something like this
hello my_user_name
The contents of variable $1 is Wallpaperama
The contents of variable $2 is Wallpapers
The contents of variable $3 is Learn
The contents of variable $0 is ./my_script
The contents of variable $* is Wallpaperama Wallpapers Learn Linux Tutorial Hosting
The contents of variable $# is 6
The contents of variable $$ is 2071
The contents of variable $1 is Wallpaperama
The contents of variable $2 is Wallpapers
The contents of variable $3 is Learn
The contents of variable $0 is ./my_script
The contents of variable $* is Wallpaperama Wallpapers Learn Linux Tutorial Hosting
The contents of variable $# is 6
The contents of variable $$ is 2071
Dexter Sat Feb 28, 2009
nice tutorial. thanks. i got my script working now.
regards.
webmaster huinda.org
regards.
webmaster huinda.org
Related Content
Information
Forums »
Linux Shell Programming Forums And Topics Discussions »
Programming With Linux Shell Tutorial By Example Passing Arguments To A Script
Linux Shell Programming Forums And Topics Discussions »
Programming With Linux Shell Tutorial By Example Passing Arguments To A Script
Title: Programming With Linux Shell Tutorial By Example Passing Arguments To A Script
Description: Programming With Linux Shell Tutorial By Example Passing Arguments To A Script
Tags: programming ,with ,linux ,shell ,tutorial ,by ,example ,passing ,arguments ,to ,a ,script
Info: This Post Has Been Viewed 0 Times Since
Date: Thu May 03, 2007
Author linux Received 1 Replies #1363
Date: Thu May 03, 2007
Author linux Received 1 Replies #1363
Share
URL: 

Embed: 

To embed this topic, just copy the code from the "Embed" box. Once you've copied the code, just paste it into your website or blog to embed it
BBCODE:: 

BBCODE is use on forums. You can put this code on all your BBCODE enabled forums like PhpBB, vBulletin® and others. Just Copy and Paste this code on your Posts and Replies on your forums
wallpaperama | Wallpapers | Forums | Terms Of Service
copyright © 2013 wallpaperama - All Rights Reserved - Last Updated Mon May 06, 2013 (-8 GMT)
Powered by: Webune Forums V5
copyright © 2013 wallpaperama - All Rights Reserved - Last Updated Mon May 06, 2013 (-8 GMT)
Powered by: Webune Forums V5