Advertisement
cd62131

n-th column are same? (q14277104369)

Mar 16th, 2023
1,069
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.34 KB | None | 0 0
  1. #!/bin/bash
  2. set -euo pipefail
  3. file=${1:-./list.txt}
  4. col=$(cat -- "$file" | head -1 | awk -F, '$0=NF')
  5. f=$(mktemp)
  6. trap 'rm -f "$f"' EXIT
  7. for ((i = 1; i <= col; ++i)); do
  8.   cat -- "$file" | cut -d, -f$i | sort -t, -u >"$f"
  9.   if (($(wc -l <"$f") > 1)); then continue; fi
  10.   # do something
  11.   n=$(grep -Po '\d+' <"$f")
  12.   echo $i "$n"
  13. done
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement