Write a script that creates a directory

Assignment Help Software Engineering
Reference no: EM13327259

chp1

1. Write a script that creates a directory calledbpl inside$HOME.Populate this directory with two subdirectories,binand scripts.
2. Write a script to create the "Hello, World!" script,hw, in$HOME/bpl/bin/; make it executable; and then execute it.

chp 2

1.What is wrong with this command?
tr A Z < $HOME/temp > $HOME/temp

2.Write a script, using$RANDOM, to write the following output both to a file and to a variable. The following numbers are only to show the format; your script should produce different numbers:
1988.2365
13798.14178
10081.134
3816.15098

chp 3

1.Write a script that asks the user to enter a number between 20 and 30. If the user enters an invalid number or a non-number, ask again. Repeat until a satisfactory number is entered.

2.Write a script that prompts the user to enter the name of a file. Repeat until the user enters a file that exists.

chp 4

1.How many arguments are there on this command line?
sa $# $(date "+%Y %m %d") John\ Doe
2.What potential problem exists with the following snippet?
year=$( date +%Y )
month=$( date +%m )
day=$( date +%d )
hour=$( date +%H )
minute=$( date +%M )
second=$( date +%S )

chp 5
1.By default, where can a variable assigned in a script be accessed? Select all that apply:
•In the current script
•In functions defined in the current script
•In the script that called the current script
•In scripts called by the current script
•In subshells of the current script
2.I advise against using single-letter variables names but give a couple of places where they are reasonable. Can you think of any other legitimate uses for them?
3.Givenvar=192.168.0.123, write a script that uses parameter expansion to extract the second number,168.

chp 6
1. Rewrite functionisvalidipusing parameter expansion instead of changingIFS.
2. Add a check to_max3to verify that all three arguments are integers.

chp 7
1.What is wrong with this code (besides the inefficiency noted at the beginning of the chapter)?
if ! echo ${PATH} |grep -q /usr/games
PATH=$PATH:/usr/games
fi
2.Write a function calledto_lowerthat does the opposite of theto_upper function in Listing 7-4.
3.Write a function, palindrome, that checks whether its command-line argument is a palindrome (that is, a word or phrase that is spelled the same backward and forward). Note that spaces and punctuation are ignored in the test. Exit successfully if it is a palindrome. Include an option to print a message as well as set the return code.
4.Write two functions,ltrimand rtrim, that trim characters in the same manner astrim but from only one side of the string, left and right, respectively.

chp 8
1. Modify thekjvfirsts script accept a command-line argument that specifies how many chapters are to be printed.
2.Why are the chapter and verse numbers inkjvfirstsformatted with%sinstead of%d?
3. Write anawkscript to find the longest verse in KJV.

chp 9
1.Write a script that stores the time it takes a command (your choice of command) to run in three variables,real, user, andsystem, corresponding to the three default times that timeprints.

chp 10
1.What is wrong withif [ $var=x ]? What should it be? Why does it give the result it does?
2.Write a function, valid_square(), that returns successfully if its sole argument is a valid SAN chessboard square or fails if it is not. Write a function to test that it works.

chp 11
1.Modify themenufunction to accept its parameters from a file.
2.Rewrite thepr1function asprxthat will behave in the manner ofpr4from
Chapter 8 but will take an option for any number of columns.
3.Add agetoptssection to thefifteengame that allows the user to select between three different board formats. Write a third format.

chp 12
1.Add code to theupload script that checks that all variables have been set to legitimate values (for example, thatportis an integer).
2.Write ausageorhelp function, and add it to theuploadscript.
3.Add an option to theuploadscript to save the configuration if it has been saved.
4.Write a script that creates a configuration file in the same form aswords.cfg, prompting the user for the information to put in it.

chp 13
1.Modify theisortandasearchfunctions to usesortandgrep, respectively, if the array exceeds a certain size.
2.Write a function that transposes rows and columns in a grid (either a single-string grid or an array). For example, transform this:
123
456
789
into this:
147
256
369
3.Convert some of the grid functions, either string or array versions, to work with grids that are not square, for example, 6×3.
4.Convert the code that parses fixed-width records into a function that accepts the line of data as the first argument, followed by thevarname=width list.

chp 14
1.Write a function,hbar, that accepts two integer arguments, a width and a color, and prints a bar of that color and width. Write a second function,hbar_at, that accepts four arguments, row, column, width and color; moves the cursor to the row and column; and passes the remaining arguments tohbar.
2.White a function,clear_area, that accepts two integer arguments, rows and columns, and clears a rectangular area of that many rows and columns.

chp 15.
1.Using thekey-funcslibrary, write a menu script that uses the function keys for selection.
2.Rewrite thekey-funcslibrary to include mouse handling, and incorporate the function into the mouse-demo script.
3.Thepasswordscript does minimal checking for invalid entries. What checking would you add?
How would you code it?

Reference no: EM13327259

Questions Cloud

What is the fixed charge coverage : (a) What is the times-interest-earned ratio - Times-interest earned If the firm's lease payments are $43,700, what is the fixed charge coverage?
What is the velocity of the hovercraft : An initially stationary hovercraft sits on a large lake. At time t=0 it accelerates due north at a rate of 1.2 m/s2 for 10 s, what is the velocity of the hovercraft at time t=40 s
Determine what should happen to the supply of money : if there are no excess reserves in the banking system and $1 billion in new reserves are created by the federal reserve, what should happen to the supply of money
Introducing a new line of executive desks : Custom Office Furniture is introducing a new line of executive desks made from a specially selected grade of walnut. Initially, three models- A, B, and C- are to be marketed
Write a script that creates a directory : Write a script that asks the user to enter a number between 20 and 30. If the user enters an invalid number or a non-number, ask again. Repeat until a satisfactory number is entered.
Balance sheet for the bryan corporation : The balance sheet for the Bryan Corporation is shown below. Sales for the year were $3,680,000, with 75 percent of sales sold on credit and income statement for J. Lo Wedding Gowns, compute the following ratios:
Describe difference in economic profit in firm nd monopolist : describe the difference in economic profit between a competitive firm and a monopolist in both the short and long run. Which should take longer to reach long-run equilibrium.
Calculate the present value of annuity : Calculate the present value of this annuity at an annual effective interest rate of 8%.
Predict one major change in the us financial environment : Predict one major change in the U.S. financial environment that may likely occur within the next five years, indicating its impact to the economy and businesses.

Reviews

Write a Review

Software Engineering Questions & Answers

  Developing domain model class diagrams

The stock levels of each item are changed by the system with each purchase. However these levels need to be manually updated by a clerk in certain cases such as shipments of items from manufacturers, refunds, exchanges, etc.

  Design user-s requirements specification for school

Design a user's requirements specification for the EasyDrive School of Motoring database system. Use a single major user view for the application (Director View)

  Create storyboards interactivity diagram object dictionary

Create storyboards interactivity diagram object dictionary and any essential scripts for an interactive program for customers of sunflower floral designs.

  Describe the use of arrays and subscripts

Be typed, double spaced, using Times New Roman font (size 12), with one-inch margins on all sides; citations and references must follow APA or school-specific format. Check with your professor for any additional instructions.

  Prepare a business case for project

Business Case - Using the information that you compiled in the project proposal, prepare a Business Case for this project.

  Draw a context diagram for the order system

Kitchen Gadgets sells a line of high-quality kitchen utensils and gadgets. When customers place orders on the company's Web site or through electronic data interchange

  Determine the greatest magnitude negative number

Determine the greatest magnitude negative number one can represent in an 8-bit 2's complement code? Write your result in binary and decimal.

  Draw flowchart to let a user play rounds of head

Draw a flowchart to let a user play 10rounds of head or tail guessing game. Display how many times the player has guessed the outcomes correctly.

  Process of requirements elicitation and validation

Give reasons why the process of requirements elicitation and validation is an iterative one and what roles does the requirement documentation play in the process of requirements elicitation and validation?

  Modularity can have negative as well as positive effect

Modularity can have a negative as well as a positive effect. A program that is overmodularized performs its operations in very small modules, so a reader has trouble acquiring an overall perspective

  Describe what actions you would take and in what sequence

Describe what actions you would take and in what sequence. How would your adjustment actions differ if the person were the lead tester?

  Create either pseudocode or flowchart for program

Create either pseudocode or a flowchart for a program that does the following: Prompt the user to enter a sales tax rate. Prompt the user to enter a price.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd