Menu

[Solved]1 Write Shell Script Records File Sizes Write Shell Script Named Sizessh Takes Name Direct Q37162476

1. Write a shell script that records file sizes Write a shell script named sizes.sh that takes the name of a directory within

Sample Output $ ./sizes.sh DLLs I ./blocks 10000 FILENAME FILESIZE INUM OF BLOCKS | SIZE OF PTRS lOVERHD ./DLLs/_bsddb.pyd /D

1. Write a shell script that records file sizes Write a shell script named sizes.sh that takes the name of a directory within the current working directory as a command-line argument and prints the name and size of each file to standard output. You may assume there are no subdirectories within the given directory The output of the shell script does not have to match the sample output shown below. However, it may be a good idea produce a consistent and structured output, because the output of this script will be read by the C program below $ ./sizes.sh DLLs ./DLLs/bsddb.pyd 1470976 DLLS/_ctypes.pyd 120832 /DLLs/_ctypes_test.pyd 16384 /DLLs/_elementtree.pyd 181248 . /DLLs/hashlib.pyd 1482240 /DLLs/_msi.pyd 23552 /DLLs/_multiprocessing.pyd 34816 /DLLs/ socket.pyd 50688 . /DLLs/ sqlite3.pyd 64000 HINT: the stat command is likely the best one to use for retrieving this data. The script should not be very long. If you find it becoming too complicated, use the man stat command to find out how to selectively retrieve information about a file 2. Write a program in C that measures the overhead Write a program in C named blocks.c that reads the filename and size information from sizes.sh, gets block size through a command-line argument, then calculates and displays the total overhead of all the files in a directory. The simulation must follow the requirements below Consider each block pointer as 8 bytes Display information for each file: * o Filename o Filesize o Number of blocks (number of blocks required to hold this file) o Size ofpointers (number of bytes used by block pointers to this file) o Overhead (number of bytes in the last block of the file that is not used) Sample Output $ ./sizes.sh DLLs I ./blocks 10000 FILENAME FILESIZE INUM OF BLOCKS | SIZE OF PTRS lOVERHD ./DLLs/_bsddb.pyd /DLLs/ctypes.pyd ./DLLs/_ctypes_test.pyd ./DLLs/_elementtree.pyd ./DLLS/hashlib.pyd ./DLLs/ msi.pyd ./DLLs/_multiprocessing.pyd /DLLs/_socket.pyd /DLLs/sqlite3.pyd /DLLS/ ssl.pyd /DLLs/testcapi.pyd /DLLs/ tkinter.pyd /DLLs/bz2.pyd /DLLs/py.ico /DLLs/pyc.ico /DLLs/pyexpat.pyd ./DLLs/select.pyd /DLLs/sqlite3.d1l ./DLLs/tc185.d11 /DLLs/tclpip85.d1l ./DLLs/tk85.d1l /DLLs/unicodedata.pyd ./DLLs/winsound.pyd 19024 19168 13616 | 8752 7760 6448 15184 19312 l 6000 19264 8800 8288 7328 |1470976 120832 116384 |181248 |1482240 123552 34816 150688 64000 2100736 51200 51712 192672 19790 19790 179712 |148 113 1184 104 152 |149 |1192 132 156 1211 11688 1210 288 | 8224 4592 1 4752 1272 6944 7776 7712 |144 116 632 1968 785408 1205248 9728 1773056 692224 12288 121 178 |1424 1560 10450076 1059 8472 1139924 |148396 TOTALS (BYTES) TOTAL OVERHEAD FOR ALL FILES (BYTES) Show transcribed image text 1. Write a shell script that records file sizes Write a shell script named sizes.sh that takes the name of a directory within the current working directory as a command-line argument and prints the name and size of each file to standard output. You may assume there are no subdirectories within the given directory The output of the shell script does not have to match the sample output shown below. However, it may be a good idea produce a consistent and structured output, because the output of this script will be read by the C program below $ ./sizes.sh DLLs ./DLLs/bsddb.pyd 1470976 DLLS/_ctypes.pyd 120832 /DLLs/_ctypes_test.pyd 16384 /DLLs/_elementtree.pyd 181248 . /DLLs/hashlib.pyd 1482240 /DLLs/_msi.pyd 23552 /DLLs/_multiprocessing.pyd 34816 /DLLs/ socket.pyd 50688 . /DLLs/ sqlite3.pyd 64000 HINT: the stat command is likely the best one to use for retrieving this data. The script should not be very long. If you find it becoming too complicated, use the man stat command to find out how to selectively retrieve information about a file 2. Write a program in C that measures the overhead Write a program in C named blocks.c that reads the filename and size information from sizes.sh, gets block size through a command-line argument, then calculates and displays the total overhead of all the files in a directory. The simulation must follow the requirements below Consider each block pointer as 8 bytes Display information for each file: * o Filename o Filesize o Number of blocks (number of blocks required to hold this file) o Size ofpointers (number of bytes used by block pointers to this file) o Overhead (number of bytes in the last block of the file that is not used)
Sample Output $ ./sizes.sh DLLs I ./blocks 10000 FILENAME FILESIZE INUM OF BLOCKS | SIZE OF PTRS lOVERHD ./DLLs/_bsddb.pyd /DLLs/ctypes.pyd ./DLLs/_ctypes_test.pyd ./DLLs/_elementtree.pyd ./DLLS/hashlib.pyd ./DLLs/ msi.pyd ./DLLs/_multiprocessing.pyd /DLLs/_socket.pyd /DLLs/sqlite3.pyd /DLLS/ ssl.pyd /DLLs/testcapi.pyd /DLLs/ tkinter.pyd /DLLs/bz2.pyd /DLLs/py.ico /DLLs/pyc.ico /DLLs/pyexpat.pyd ./DLLs/select.pyd /DLLs/sqlite3.d1l ./DLLs/tc185.d11 /DLLs/tclpip85.d1l ./DLLs/tk85.d1l /DLLs/unicodedata.pyd ./DLLs/winsound.pyd 19024 19168 13616 | 8752 7760 6448 15184 19312 l 6000 19264 8800 8288 7328 |1470976 120832 116384 |181248 |1482240 123552 34816 150688 64000 2100736 51200 51712 192672 19790 19790 179712 |148 113 1184 104 152 |149 |1192 132 156 1211 11688 1210 288 | 8224 4592 1 4752 1272 6944 7776 7712 |144 116 632 1968 785408 1205248 9728 1773056 692224 12288 121 178 |1424 1560 10450076 1059 8472 1139924 |148396 TOTALS (BYTES) TOTAL OVERHEAD FOR ALL FILES (BYTES)

Expert Answer


Answer to 1. Write a shell script that records file sizes Write a shell script named sizes.sh that takes the name of a directory w… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *