
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Write a Shell script that accepts a list of file names as arguments and counts and reports the occurrence of each word that is present in the first argument file in other argument files.
![Write a Shell script that accepts a list of file names as arguments and counts and reports the occurrence
of each word that is present in the first argument file in other argument files.
Hint:
Tr: can be used to replace a given string with another string.
Syntax: Tr [original string] [replacement string]
Grep: can be used for searching a regular pattern in a given file.
Syntax: Grep [ pattern ] file name
Result:
if [ $# -eq 0 ]
then
echo "no arguments"
else
tr "
" < $1 > temp
shift
for i in $*
do
tr " " "
" < $i > templ
y='wc -1 < temp`
j=1
while [$j -le $y ]
do
x= `head -n $j temp | tail -1`
c=`grep -c "$x" temp1`
echo $x $c
j=`expr $j 1`
done
done
fi](https://content.bartleby.com/qna-images/question/5acd3559-5b15-45b4-a401-297419b5ec46/92af1c5a-eaf2-4860-9978-1b526be55e95/o2rnnf_thumbnail.jpeg)
Transcribed Image Text:Write a Shell script that accepts a list of file names as arguments and counts and reports the occurrence
of each word that is present in the first argument file in other argument files.
Hint:
Tr: can be used to replace a given string with another string.
Syntax: Tr [original string] [replacement string]
Grep: can be used for searching a regular pattern in a given file.
Syntax: Grep [ pattern ] file name
Result:
if [ $# -eq 0 ]
then
echo "no arguments"
else
tr "
" < $1 > temp
shift
for i in $*
do
tr " " "
" < $i > templ
y='wc -1 < temp`
j=1
while [$j -le $y ]
do
x= `head -n $j temp | tail -1`
c=`grep -c "$x" temp1`
echo $x $c
j=`expr $j 1`
done
done
fi
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps

Knowledge Booster
Similar questions
- Can you answer 12 and 13?arrow_forwardWrite a C program that, given a text file, constructs Huffman code based on the character frequencies of the file and then encodes the file accordingly. The executable must accept the following command line options:• -i filename for the input file • -o filename for the output filearrow_forwardAnswer quickly in pythonarrow_forward
- Write a C program that, given a text file, constructs Huffman code based on the character frequencies of the file and then encodes the file accordingly. The executable must accept the following command line options:• -i filename for the input file • -o filename for the output file Use the fread function, use FILE, size, etc. Please use the following to write the code: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <getopt.h>arrow_forwardGiven an initialised variable fileName, write a series of instructions that produces a file with the name indicated by fileName and a single line stating "This Is File:" followed by the file's name. Verify that the data written to the file has been purged from its buffer and that all system resources utilised by these statements have been freed. (Don't worry about exceptions; presume they're handled elsewhere.)arrow_forwardGiven an initialized variable fileName, write a series of instructions that produces a file with the name indicated by fileName and a single line stating "This Is File:" followed by the file's name. Verify that the data written to the file has been purged from its buffer and that all system resources utilized by these statements have been freed. (Don't bother about exceptions; presume they're handled elsewhere.)?arrow_forward
- Bash Shell Script Programming Assignment **Make sure to name the script file as it mentions** Question 1. Create a shell script file called q1.sh Write a script that would accept the two strings from the console and would display a message stating whether the accepted strings are equal to each other. Question 2. Create a shell script file called q2.sh Write a bash script that takes a list of files in the current directory and copies them as into a sub-directory named mycopies. Question 3. Create a shell script file called q3.sh Write a Bash script that takes the side of a cube as a command line argument and displays the volume of the cube. Question 4. Create a shell script file called q4.sh Write a Bash script that prompts you for a user name and displays the corresponding user’s id number (UID), group id number (GID), and his/her home directory. Note: this information can be found in the /etc/passwd file. Question 5. Create a shell script file called q4.sh Write a bash…arrow_forwardThe Payroll Department keeps a list of employee information for each pay period in a text file. The format of each line of the file is the following: <last name> <hours worked> <hourly wage> Write a program that inputs a filename from the user and prints to the terminal a report of the wages paid to the employees for the given period. The report should be in tabular format with the appropriate header. Each line should contain: An employee’s name The hours worked The wages paid for that period. An example of the program input and output is shown below: Enter the file name: data.txt Name Hours Total Pay Lambert 34 357.00 Osborne 22 137.50 Giacometti 5 503.50arrow_forwardDraft a Python program that prompts the user for the name of two files. The script should copy the lines of text from the input file to the output file, numbering each line as it goes. The line numbers should be right-justified in 4 columns, so that the format of a line in the output file looks like this example:arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY