Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For this task, assume that we have a file that contains a list of file names, on

ID: 3684339 • Letter: F

Question

For this task, assume that we have a file that contains a list of file names, one per line. Write a bash script that takes the name of cuh a file as its command line argument. Its otput will be , for each file named in that file, the file name and the number of bytes in that file, in the format

file: 93345

If the file does not exist or cannot be opened there should be no line in the output for that file. After all the files and their size have been displayed, the script should display the total number of bytes in the "large" files on a single line. For this purpose, a file is considered large of its size is greater than 100,00 bytes. To be clear, the sum is only the sum of those fiels whose size is at least 100,000 bytes. Name the script filesize.

Explanation / Answer

Linux wc Command Examples

The wc utility in Linux is used print information like number of newlines, words, byte counts of a file.

Here is the syntax and description from man page :

SYNOPSIS
wc [OPTION]… [FILE]…
wc [OPTION]… –files0-from=F

DESCRIPTION

Print newline, word, and byte counts for each FILE, and a total line if more than one FILE is specified. With no FILE, or
when FILE is -, read standard input. A word is a non-zero-length sequence of characters delimited by white space.

1.The word count of a file can be displayed explicitly through -w option.

2.Display number of newlines through -l option

The wc command provides an option -l through which number of newlines can be displayed in the output.

Here is an example :

3.Display number of bytes through -c option

Total number of bytes in a file can be displayed by using -c option of the wc command.

Here is an example :

Note:-Just use the above commands you will get the output.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote