blob: 1c6eb1b286b18863d343854d0ef9428c9ebde4a4 [file] [log] [blame]
David Brazdil2200a1b2018-05-05 12:07:38 +01001#!/bin/bash
2set -e
3if [ -z "$1" ]; then
4 source_list=/dev/stdin
5 dest_list=/dev/stdout
6else
7 source_list="$1"
8 dest_list="$1"
9fi
10# Load the file
11readarray A < "$source_list"
12# Sort
13IFS=$'\n'
14A=( $(LC_COLLATE=C sort -f <<< "${A[*]}") )
15A=( $(uniq <<< "${A[*]}") )
16unset IFS
17# Dump array back into the file
18printf '%s\n' "${A[@]}" > "$dest_list"