

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The subject name, code, and instructions for practical 3 of the operating system course (2cs304). The practical includes writing a shell script to compare the contents of two files and another script to generate all combinations of three numbers. The code and input-output examples are provided.
Typology: Exercises
1 / 3
This page cannot be seen from the preview
Don't miss anything!


a) Write a shell script to compare the contents of two files. Code: file1="/home/priyal/test1.txt" file2="/home/priyal/test2.txt" if cmp -s "$file1" "$file2"; then printf 'The file "%s" is the same as "%s"\n' "$file1" "$file2" else printf 'The file "%s" is different from "%s"\n' "$file1" "$file2" Fi Input and Output: b) Write a shell script to generate all the combinations of 1, 2 and 3.
Code: echo "Enter three numbers" read a read b read c for i in $a $b $c do for j in $a $b $c do if [ $j != $i ] then for k in $a $b $c do if [ $k != $i ]&&[ $k != $j ] then echo $i $j $k; fi done fi done Done Input and Output: