Write a script that creates a directory|Software Engineering

Write a script that creates a directory|Software Engineering

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?

Order from us and get better grades. We are the service you have been looking for.