Programming With Linux Shell Tutorial By Example Passing Arguments To A Script



Programming With Linux Shell Tutorial By Example Passing Arguments To A Script
 (382) Find work at Home Jobs
Programming With Linux Shell Tutorial By Example Passing Arguments To A Script
Post Description:
Post Tags: programming, with, linux, shell, tutorial, by, example, passing, arguments, to, a, script
This Post Has Been Viewed 975 Times Since Thu May 03, 2007 9:40 pm Posted By linux with 0 replies
Next Post »» creating a linux shell script with variable with user input form prompt to enter data
Programming With Linux Shell Tutorial By Example Passing Arguments To A Script
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
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 ' $$

* 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

Leave Your Comments     [ dejar commentarios ]
  * Name     [nombre]

  * eMail (will not be published)     [coreo electronico]

* Enter Your Reply or Comments:    [commentarios]


Add Picture To Comments         [incluir foto]
YES NO             upload
Receive Replies on my Comments (An email will be sent to you when someone replies to your comments)

     

Comments and replies About Programming With Linux Shell Tutorial By Example Passing Arguments To A Script




(0) Comments