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

The following shell script myUniq is used to create a frequency list of every wo

ID: 3740748 • Letter: T

Question

The following shell script myUniq is used to create a frequency list of every word in a file. When running the shell script, the first argument should be the pathname of the file to be checked. Assume we have a file as below: This is a test Test test test There are multiple tests After running the shell script, a two-column list is displayed on the screen. The first column shows what words appear, the second column shows how often they appear, for example: $./myUniq.sh test

test@3

tests@1

multiple@1

is@1

are@1

a@1

This@1

There@1

Test@1

The lines are sorted by the frequency. cat $1 | tr ' ' ' ' > temp # put all words to a new line

echo -n > file2.txt # clear file2.txt for line in _______A._______ # trace each line from temp file do

# check if the current line is visited grep -q _______B._______ file2.txt if [_______C._______] then count=`_______D.___________`

#count the number of words echo $line"@"$count >> file2.txt

# add word and frequency to file fi done sort _______E._______ file2.txt # sort the lines according to thefrequency

The following Bourne shell script and C program can accomplish the same task:
read an IP address from user's input and check if the input IP address is valid or not.
Shell script
#!/bin/bash
echo -n "Please enter the ip:"
_______A._______
echo $ip|grep _______B.______________
if [_______C._______]
then
echo "Please enter IP address following the
IP address pattern"
exit
fi

C programm
#include<stdio.h>
int main(){
int ip1=0,ip2=0,ip3=0,ip4=0;
int n=0;
n=scanf("_______A2._________",
_______B2.__________);
if (n!=4) {
printf("Please enter IP address
following the IP address pattern");

Explanation / Answer

NOTE: I have completed your assignment. Please check and let me know if you find any issues. I will revert back within 24 hours. thanks for your patience.

1) For the first shell script i have given answers below with listing A, B etc and its answers. Please check.
A) cat temp
B) $line
C) $? -eq 0 # to check if grep command is successful
D) expr $count + 1
E) -t'@' -k2 # to sort by word lenght frequency

2) For the second shell script i have given answers below with listing A, B etc and its answers. Please check.
A) read ip
B) -E 'd{1,3}.d{1,3}.d{1,3}.d{1,3}'
C) $? -ne 0


3) For the third C program i have given answers below with listing A, B etc and its answers. Please check.
scanf("%u.%u.%u.%u", &ip1, &ip2, &ip3, &ip4);
is the scanf statement to read the four octets of IP address into ip1, ip2, ip3 and ip4.
A2) %u.%u.%u.%u
to read four unsigned integers
B2) &ip1, &ip2, &ip3, &ip4
to read four IP integers


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