Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Check if the correct number of arguments is provided
- if [ "$#" -ne 4 ]; then
- echo "Usage: $0 <File1> <File2> <OutputFile1> <OutputFile2>"
- exit 1
- fi
- file1=$1
- file2=$2
- output1=$3
- output2=$4
- # Function to compare values and generate output
- compare_and_output() {
- while IFS=" " read -r id1 col1 _; do
- IFS=" " read -r id2 col2 _
- if [ "$col1" != "$col2" ]; then
- echo "$id1 $col1 $col2" >> "$output1"
- echo "$col1 $col2" >> "$output2"
- fi
- done < <(paste <(cut -d" " -f2,3 "$file1") <(cut -d" " -f2,3 "$file2"))
- }
- # Compare values and generate output
- compare_and_output
- # Count occurrences of each unique qualitative difference
- sort "$output2" | uniq -c > "$output2.tmp"
- mv "$output2.tmp" "$output2"
- echo "Comparison completed. Results saved in $output1 and $output2."
Advertisement
Add Comment
Please, Sign In to add comment