

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
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: