
Exploring Shell Scripting Variables and Parameters
Dive into the world of Linux shell scripting as we explore the use of variables, keyboard input, and positional parameters. Learn how to create scripts that interact with users and utilize backticks for special use cases. Discover the flexibility and power of untyped variables in Linux scripting, paving the way for efficient and dynamic script execution.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
CIS117 Week 9 SHELLSCRIPTING, NOW WITH VARIABLES
Beyond the basics Getting keyboard input Variables Variables in Linux are untyped Any word (that isn't reserved) can be a variable Use $ to use variable https://www.explainxkcd.com/wiki/index.php/1513:_Cod e_Quality
DEMO Small script asking for name and then saying hello $name #!/bin/bash Echo "What's your name?" Read name Echo "Hello $name" https://www.explainxk cd.com/wiki/index.ph p/1695:_Code_Quality _2
Positional parameters Used to pass info to a script when executed Numbered starting at 1 with some special parameters (such as $* and $?) Example and DEMO ./testscript.sh Jane #puts Jane as $1 echo "hello $1" #should say hello Jane ./testscript.sh Jane Doe #should put Jane as $1 and Doe $2 echo "hello $1 $2" # should say hello Jane Doe
Special use case positional parameters and backticks Command of date Then use set `date` (backticks not single quote) Puts the results in positional parameters DEMO use case https://www.explainxk cd.com/wiki/index.ph p/1833:_Code_Quality _3