The document provides instructions for writing a shell script that counts empty lines in a file passed as a command line argument. The script must validate: 1) the correct number of arguments are passed, 2) the input file exists, 3) the input file is an ordinary file, and 4) the input file is readable. The script should print error messages for any failed validations or the empty line count. Examples of expected output are provided.
The document provides instructions for writing a shell script that counts empty lines in a file passed as a command line argument. The script must validate: 1) the correct number of arguments are passed, 2) the input file exists, 3) the input file is an ordinary file, and 4) the input file is readable. The script should print error messages for any failed validations or the empty line count. Examples of expected output are provided.
The document provides instructions for writing a shell script that counts empty lines in a file passed as a command line argument. The script must validate: 1) the correct number of arguments are passed, 2) the input file exists, 3) the input file is an ordinary file, and 4) the input file is readable. The script should print error messages for any failed validations or the empty line count. Examples of expected output are provided.
sh, write a shell script to find the count of empty lines in a
given file. The filename will be given as command line argument. Incorporate the following validations in the script : i. Whether correct number of command line arguments are passed while running the script or not. ii. Whether the given input file exists or not. iii.Whether the given input file is an ordinary file or not. iv. Whether the given input file is readable or not. Print appropriate messages in each case as per the messages shown in the example below. To save your code, please press Ctrl+S in the project explorer. Examples : Note : Please refer to the files in the project explorer for understanding the below examples. i. If the script is executed as bash script.sh, the output should be Pass appropriate number of command line arguments ii. If the script is executed as bash script.sh abc.txt where abc.txt is the input file then, the output should be Input file does not exist iii. If the script is executed as bash script.sh myDir where myDir is the input file, but myDir is a directory file not an ordinary file, then, output should be Input file is not an ordinary file iv. If the script is executed as bash script.sh testfile where testfile is the input file, but testfile does not have read permission, then, the output should be Input file does not have read permission v. If the script is executed as bash script.sh data.txt where data.txt is the input file , then the output should be 0 vi. If the script is executed as bash script.sh processes.txt where processes.txt is the input file , then the output should be 5 Note : Please print the exact messages as shown in the examples in your script. If you do not use the exact message the test cases will not pass. Once you have completed writing your code, you can click on Run -> Run Server to check the output of your script. You can also try to execute your script from the command prompt by clicking on the New terminal button on the right side top corner of the project explorer. Also, you can check the status of the test cases by clicking on Run - > Test. The status of the test cases will be shown on the terminal. Please check the file testCases.txt for additional details of the test cases.