Please explain the following for making bash scripts:
Statements to keep in mind
if-then-fi; if-then-else-fi and if-then-elif-then-else-fi
the evaluation of a single/compound condition
while-do-done and until-do-done
the evaluation of a single/compound condition
for-done
for every item in a list
another usage of for will need the evaluation of a single/compound condition
case-in-esac
Answer:-
if-then-fi; if-then-else-fi and if-then-elif-then-else-fi:-
The if statement allows you to specify courses of action to be taken in a shell script, depending on the success or failure of some command. It is a conditional statement that allows a test before performing another statement. The syntax for the simplest form is:
if [ condition ]
then
block_of_statements
fi
Here,
while-do-done and until-do-done:-
The while loop is used to performs a given set of commands an unknown number of times as long as the given condition evaluates to true.
The Bash while loop takes the following form:
while [CONDITION] do [COMMANDS] done
Copy
The condition is evaluated before executing the commands. If the condition evaluates to true, commands are executed. Otherwise if the condition evaluates to false the loop will be terminated and the program control will be passed to the command
for-done:-
Numeric ranges for syntax is as follows:
for VARIABLE in 1 2 3 4 5 .. N
do
command1
command2
commandN
done |
OR
for VARIABLE in file1 file2 file3
do
command1 on $VARIABLE
command2
commandN
done |
OR
for OUTPUT in $(Linux-Or-Unix-Command-Here)
do
command1 on $OUTPUT
command2 on $OUTPUT
commandN
done |
Examples
This type of for loop is characterized by counting. The range is specified by a beginning (#1) and ending number (#5). The for loop executes a sequence of commands for each member in a list of items.
Please explain the following for making bash scripts: Statements to keep in mind if-then-fi; if-then-else-fi...
Need help with Python (BinarySearch), code will be below after my statements. Thank you. Have to "Add a counter to report how many searches have been done for each item searched for." Have to follow this: 1) you'll create a counter variable within the function definition, say after "the top = len(myList)-1" line and initialize it to zero. 2) Then within the while loop, say after the "middle = (bottom+top)//2" line, you'll start counting with "counter += 1" and 3)...
Please write a BASH Script in LINUX that... 1. is actually executable 2. has a comment to tell us what you did, why and how. 3. allows a user to enter their name and a number between 1 than 100 (this must be prompted so the user knows what to do) 4. creates a random number between 1 and 100 for you to guess. The command to create a random number is shown below. (if you find a better one...use...
Been working on this program for hours and keep getting error. PLEASE help and show a working output, Thank you Step 2: Declaring variables Examining the problem we need to have 2 variable to store integer input given by the user. int x,y; Step 3: setting up Scanner object and scanning the inputs import java.util.Scanner; Create Scanner class object by using following syntax Scanner=new Scanner(System.in); /* give some name to the object which ever you want */ Ask the...
Objectives – to practice these new concepts: decision-making with if, if-else, if-else-if-… switch data validation for user input using a while (or while/do) loop nicely formatted output report with printf and format strings multiple input data sets using a while (or while/do) loop named constants PROJECT OVERVIEW This project provides a detailed payroll report for the sales staff at TheLaptopShop. The company has 3 tiers of salespeople: low, middle, high (designated by L, M, H) – based on their past...
Please answer the case questions. Do not hand write
CASE: SPOUSAL RIGHTS IN DECISION MAKING Mr. Martin sustained debilitating injuries as the result of an automobile accident. He suffered severe subcortical brain damage, significantly impairing his physical and cognitive function- ing.45 His injuries left him totally paralyzed on the left side. He could not speak or eat and had no bladder or bowel control. Martin remained conscious and had some awareness of his surroundings. He could communicate to a very...
The ability of computers to perform complex tasks is built on combining simple commands into control structures. Of these control structures, blocks, while loop, the do..while loop, and the for loop. A block is the simplest type of structured statement. Its purpose is simply to group a sequence of statements into a single statement. The format of a block is: { } Here are two examples of blocks: { System.out.print("The answer is "); System.out.println(ans); } // This block exchanges the...
CSC 130 Lab Assignment 8 – Program Menu Create a C source code file named lab8.c that implements the following features. Implement this program in stages using stepwise refinement to ensure that it will compile and run as you go. This makes it much easier to debug and understand. This program presents the user a menu of operations that it can perform. The choices are listed and a prompt waits for the user to select a choice by entering a...
Please do not hand write ***
CASE: SPOUSAL RIGHTS IN DECISION MAKING Mr. Martin sustained debilitating injuries as the result of an automobile accident. He suffered severe subcortical brain damage, significantly impairing his physical and cognitive function- ing.45 His injuries left him totally paralyzed on the left side. He could not speak or eat and had no bladder or bowel control. Martin remained conscious and had some awareness of his surroundings. He could communicate to a very minimal degree through...
Read Case #1 entitled "Understanding Your Employee Benefits: Qualifying for Unemployment Benefits" on pages 214-215 of your text and answer these 3 case questions. Are you eligible to receive unemployment if you resign? Explain your answer. Should you resign or wait to find out if and when you are laid off? Elaborate. Explain the criteria to qualify for unemployment benefits and relate the criteria to this case study. 150 words During the three years that you have worked at your...
C LANGUAGE. PLEASE INCLUDE COMMENTS :)
>>>>TheCafe V2.c<<<<
#include <stdio.h>
int main()
{
int fries; // A flag denoting whether they want fries or not.
char bacon; // A character for storing their bacon preference.
double cost = 0.0; // The total cost of their meal, initialized to start at 0.0
int choice; // A variable new to version 2, choice is an int that will store the
// user's menu choice. It will also serve as our loop control...