Write a Shell script that accepts a list of file names as its arguments, counts and reports the occurrence of each word that is present in the first argument file on other argument files.
AIM:
Write a Shell script that accepts a list of file names as its arguments, counts and reports the occurrence of each word that is present in the first argument file on other argument files.
Program:
if [ $# -eq 0 ] then echo "no arguments" else tr " " " " < $1 > temp shift for i in $* do tr " " " " < $i > temp1 y=`wc -l < 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
Output:
$sh 9a.sh hegde.sh ravi.sh Raghu 2 Hary 1 Vinay 9
-
UpdatedOct 23, 2014
-
Views21,849
Write a Shell script to find factorial of a given integer.
Write in C the following Unix commands using system calls A). cat B). ls C). mv
Write a Shell script that displays list of all the files in the current directory to which the user has read, Write and execute permissions.
Write a Shell script that accepts a filename, starting and ending line numbers as arguments and displays all the lines between the given line numbers.
Write a C program to emulate the Unix ls-l command.
Write a Shell script to list all of the directory files in a directory.