0% found this document useful (0 votes)
5 views1 page

Shell Script for Word Count in Replit

The document contains a shell script designed to count and report the occurrences of each word from a specified file in other provided files. It checks for the presence of arguments and processes the first argument file to extract words, then compares them against the subsequent files. The script outputs the word count for each word found in the first file across the other files.

Uploaded by

23b01a1253
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Shell Script for Word Count in Replit

The document contains a shell script designed to count and report the occurrences of each word from a specified file in other provided files. It checks for the presence of arguments and processes the first argument file to extract words, then compares them against the subsequent files. The script outputs the word count for each word found in the first file across the other files.

Uploaded by

23b01a1253
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

10/31/23, 11:53 AM shell script - Replit

shell script Invite Deploy

[Link] f1 f2 f3 Console Shell

[Link]

1 # [Link]:22b01a12g0 Name:[Link]
2 # Experiment No:5A
3 # write a shell script that accepts a list of file namesas its
arguments,counts and reports the occurence of each word that is
present in the first argument file on other argument files.
4 #!/bin/bash
5 if [ $# -eq 0 ]
6 then
7 echo "NO arguments"
8 else
9 tr " " "\n" < $1 >temp
10 shift
11 for i in $*
12 do
13 tr " " "\n" < $i >temp1
14 y=`wc -l <temp`
15 j=1
16 while [ $j -le $y ]
17 do
18 x=`head -n $j temp | tail -1`
19 c=`grep -c "$x" temp1`
20 echo $x $c
21 j=`expr $j + 1`
22 done
23 done
24 fi

[Link] 1/1

You might also like