File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -35,13 +35,16 @@ <h1>How to find duplicates in a column</h1>
3535</ ul > </ li >
3636</ ul >
3737
38- < p > Here’s an example Bash script looking for duplicates in < em > myfile .csv</ em >
38+ < p > Here’s an example Bash script looking for duplicates in < em > dups .csv</ em >
3939in column 1 (the 2nd column of the CSV file)</ p >
4040
41- < pre > < code class ="language-shell "> cat myfile.csv | csvcol -f 1 | sort -u | while read CELL; do
42- if [ "$CELL" != "" ]; then
43- csvfind -i myfile.csv -trim-spaces -col 1 "$CELL"
44- fi
41+ < pre > < code class ="language-shell "> CSV_FILE="dups.csv"
42+ CSV_COL_NO="1"
43+
44+ csvcols -i "$CSV_FILE" -col "$CSV_COL_NO" | sort -u | while read CELL; do
45+ if [ "$CELL" != "" ]; then
46+ csvfind -i "$CSV_FILE" -trim-spaces -col "$CSV_COL_NO" "${CELL}"
47+ fi
4548 done
4649</ code > </ pre >
4750
You can’t perform that action at this time.
0 commit comments