|
1. Write a SHELL program that accepts a number in the range of 2-15 as a parameter. Use the + sign,-sign, and vertical bar (|) to draw a square with the given parameter value as an edge on the standard output device. If the number of parameters on the command line is incorrect or the value is out of range, a corresponding error message is displayed.
+ ———— +
| |
| |
+ ———— +
2. Write a SHELL program so that it accepts only one command-line parameter. Use this parameter to enter a directory and calculate the total number of lines for all text files in that directory (excluding subdirectories).
For example, there are three text files 1.txt, 2.txt, and 3.txt in a certain directory, which are 3 lines, 20 lines, and 19 lines. Then the statistical result should be 42 lines.
If a command line parameter is entered as a file, an error message is displayed.
3. Write a Shell program to check whether the specified user is logged in to the system. If logged in, it will display "xxx user is logged in" and return 0, otherwise it will display "xxx user is logged in to the system" and return 1. |
|