#!/bin/bash # Check if a file path is provided if [ "$#" -ne 1 ]; then echo "Usage: $0 " exit 1 fi # Assign the file path to a variable file_path="$1" # Check if the file exists if [ ! -f "$file_path" ]; then echo "Error: File does not exist." exit 1 fi # Read each line from the file and count the number of fields while IFS= read -r line; do # Count the number of tabs, add 1 for the number of columns col_count=$(echo -n "$line" | grep -o $'\t' | wc -l) let col_count+=1 # Check if the number of columns is 2 if [ "$col_count" -ne 2 ]; then echo "Error: Incorrect number of columns. Expected 4, but got $col_count in line: $line" exit 1 fi done < "$file_path" echo "All rows have the correct number of columns."