Skip to content

Commit ccc0896

Browse files
committed
commiting to master
1 parent 0ec064a commit ccc0896

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

how-to/find-duplicates-in-a-column.html

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,16 @@ <h1>How to find duplicates in a column</h1>
3535
</ul></li>
3636
</ul>
3737

38-
<p>Here&rsquo;s an example Bash script looking for duplicates in <em>myfile.csv</em>
38+
<p>Here&rsquo;s an example Bash script looking for duplicates in <em>dups.csv</em>
3939
in 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 [ &quot;$CELL&quot; != &quot;&quot; ]; then
43-
csvfind -i myfile.csv -trim-spaces -col 1 &quot;$CELL&quot;
44-
fi
41+
<pre><code class="language-shell"> CSV_FILE=&quot;dups.csv&quot;
42+
CSV_COL_NO=&quot;1&quot;
43+
44+
csvcols -i &quot;$CSV_FILE&quot; -col &quot;$CSV_COL_NO&quot; | sort -u | while read CELL; do
45+
if [ &quot;$CELL&quot; != &quot;&quot; ]; then
46+
csvfind -i &quot;$CSV_FILE&quot; -trim-spaces -col &quot;$CSV_COL_NO&quot; &quot;${CELL}&quot;
47+
fi
4548
done
4649
</code></pre>
4750

0 commit comments

Comments
 (0)