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

1. Create a sub directory “cs232hw7” under your home directory 2. Download all h

ID: 3573459 • Letter: 1

Question

1. Create a sub directory “cs232hw7” under your home directory

2. Download all https://github.com/aws/aws-iot-device-sdk-embedded-C/ sub directories under cs232hw7

3. Write a shell script to do the following Find out all unique .h files included in all *.c files, and save the output in a file called “includeheaders.txt” with one .h file per line (Unix commands grep, sort, and uniq may be useful) For each .h file in includeheaders.txt, list the number of *.c file including .h file, and save the output in a file called “headerInclusionNumber.txt” with one .h file per line e.g. stdio.h 20 (Unix command grep may be useful)

include shell script file, includeheaders.txt , and headerInclusionNumber.txt

Explanation / Answer

shell script:

#!/bin/sh
find /home/prashanth/Desktop/cs232hw7 -name "*.h" -print >> headers.txt
tr '/' ' ' < headers.txt >delimitedHeaderFiles.txt
awk '{print $NF}' delimitedHeaderFiles.txt > onlyHeaderFiles.txt
sort onlyHeaderFiles.txt | uniq -u > includeheaders.txt
while read p; do
count=$(grep -r --include *.c $p . | wc -w)
echo $p $count >> headerInclusionNumber.txt
done < includeheaders.txt

includeheaders.txt contents:

aws_iot_error.h
aws_iot_integ_tests_config.h
aws_iot_json_utils.h
aws_iot_log.h
aws_iot_mqtt_client_common_internal.h
aws_iot_mqtt_client.h
aws_iot_mqtt_client_interface.h
aws_iot_shadow_actions.h
aws_iot_shadow_interface.h
aws_iot_shadow_json_data.h
aws_iot_shadow_json.h
aws_iot_shadow_key.h
aws_iot_shadow_records.h
aws_iot_test_integration_common.h
aws_iot_tests_unit_helper_functions.h
aws_iot_tests_unit_mock_tls_params.h
aws_iot_tests_unit_shadow_helper.h
aws_iot_version.h
jsmn.h
network_interface.h
threads_interface.h
threads_platform.h
timer_interface.h
timer_platform.h

headerInclusionNumber.txt contents:

aws_iot_error.h 4
aws_iot_integ_tests_config.h 2
aws_iot_json_utils.h 8
aws_iot_log.h 48
aws_iot_mqtt_client_common_internal.h 12
aws_iot_mqtt_client.h 8
aws_iot_mqtt_client_interface.h 22
aws_iot_shadow_actions.h 10
aws_iot_shadow_interface.h 16
aws_iot_shadow_json_data.h 17
aws_iot_shadow_json.h 10
aws_iot_shadow_key.h 4
aws_iot_shadow_records.h 6
aws_iot_test_integration_common.h 8
aws_iot_tests_unit_helper_functions.h 26
aws_iot_tests_unit_mock_tls_params.h 14
aws_iot_tests_unit_shadow_helper.h 2
aws_iot_version.h 8
jsmn.h 6
network_interface.h 8
threads_interface.h 2
threads_platform.h 2
timer_interface.h 2
timer_platform.h 4