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>
35
35
</ ul > </ li >
36
36
</ ul >
37
37
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 >
39
39
in column 1 (the 2nd column of the CSV file)</ p >
40
40
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
45
48
done
46
49
</ code > </ pre >
47
50
You can’t perform that action at this time.
0 commit comments